evennia.contrib.rpg.traits.tests

Unit test module for Trait classes.

class evennia.contrib.rpg.traits.tests.TraitHandlerTest(methodName='runTest')[source]

Bases: evennia.contrib.rpg.traits.tests._TraitHandlerBase

Testing for TraitHandler

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_add_trait()[source]
test_cache()[source]

Cache should not be set until first get

test_setting()[source]

Don’t allow setting stuff on traithandler

test_getting()[source]

Test we are getting data from the dbstore

test_all()[source]

Test all method

test_remove()[source]

Test remove method

test_clear()[source]

Test clear method

test_trait_db_connection()[source]

Test that updating a trait property actually updates value in db

Test traits related to each other via Trait.get_trait()

class evennia.contrib.rpg.traits.tests.TestTrait(methodName='runTest')[source]

Bases: evennia.contrib.rpg.traits.tests._TraitHandlerBase

Test the base Trait class

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_init()[source]
test_validate_input__valid()[source]

Test valid validation input

test_validate_input__fail()[source]

Test failing validation

test_trait_getset()[source]

Get-set-del operations on trait

test_repr()[source]
class evennia.contrib.rpg.traits.tests.TestTraitStatic(methodName='runTest')[source]

Bases: evennia.contrib.rpg.traits.tests._TraitHandlerBase

Test for static Traits

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_init()[source]
test_value()[source]

value is (base + mod) * mult

test_delete()[source]

Deleting resets to default.

class evennia.contrib.rpg.traits.tests.TestTraitCounter(methodName='runTest')[source]

Bases: evennia.contrib.rpg.traits.tests._TraitHandlerBase

Test for counter- Traits

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_init()[source]
test_value()[source]

value is (current + mod) * mult, where current defaults to base

test_boundaries__minmax()[source]

Test range

test_boundaries__bigmod()[source]

add a big mod

test_boundaries__change_boundaries()[source]

Change boundaries after base/mod change

test_boundaries__disable()[source]

Disable and re-enable boundaries

test_boundaries__inverse()[source]

Set inverse boundaries - limited by base

test_current()[source]

Modifying current value

test_delete()[source]

Deleting resets to default.

test_percentage()[source]

Test percentage calculation

test_descs()[source]

Test descriptions

class evennia.contrib.rpg.traits.tests.TestTraitCounterTimed(methodName='runTest')[source]

Bases: evennia.contrib.rpg.traits.tests._TraitHandlerBase

Test for trait with timer component

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_timer_rate(mock_time)[source]

Test time stepping

test_timer_ratetarget(mock_time)[source]

test ratetarget

class evennia.contrib.rpg.traits.tests.TestTraitGauge(methodName='runTest')[source]

Bases: evennia.contrib.rpg.traits.tests._TraitHandlerBase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_init()[source]
test_value()[source]

value is current, where current defaults to base + mod

test_boundaries__minmax()[source]

Test range

test_boundaries__bigmod()[source]

add a big mod

test_boundaries__change_boundaries()[source]

Change boundaries after current change

test_boundaries__disable()[source]

Disable and re-enable boundary

test_boundaries__inverse()[source]

Try to set reversed boundaries

test_current()[source]

Modifying current value

test_delete()[source]

Deleting resets to default.

test_percentage()[source]

Test percentage calculation

test_descs()[source]

Test descriptions

class evennia.contrib.rpg.traits.tests.TestTraitGaugeTimed(methodName='runTest')[source]

Bases: evennia.contrib.rpg.traits.tests._TraitHandlerBase

Test for trait with timer component

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_timer_rate(mock_time)[source]

Test time stepping

test_timer_ratetarget(mock_time)[source]

test ratetarget

class evennia.contrib.rpg.traits.tests.TestNumericTraitOperators(methodName='runTest')[source]

Bases: evennia.utils.test_resources.BaseEvenniaTestCase

Test case for numeric magic method implementations.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

test_pos_shortcut()[source]

overridden unary + operator returns value property

test_add_traits()[source]

test addition of Trait objects

test_sub_traits()[source]

test subtraction of Trait objects

test_mul_traits()[source]

test multiplication of Trait objects

test_floordiv()[source]

test floor division of Trait objects

test_comparisons_traits()[source]

test equality comparison between Trait objects

test_comparisons_numeric()[source]

equality comparisons between Trait and numeric

class evennia.contrib.rpg.traits.tests.DummyCharacter[source]

Bases: evennia.contrib.rpg.traits.tests._MockObj

strength

Allows for applying traits as individual properties directly on the parent class instead for properties on the .traits handler. So with this you could access data e.g. as character.hp.value instead of character.traits.hp.value. This still uses the traitshandler under the hood.

Example:

from evennia.utils import lazy_property
from evennia.contrib.rpg.traits import TraitProperty

class Character(DefaultCharacter):

    strength = TraitProperty(name="STR", trait_type="static", base=10, mod=2)
    hunting = TraitProperty("Hunting Skill", trait_type="counter",
                            base=10, mod=1, max=100)
    health = TraitProperty(trait_type="gauge", min=0, base=100)
Type

Optional extra

hunting

Allows for applying traits as individual properties directly on the parent class instead for properties on the .traits handler. So with this you could access data e.g. as character.hp.value instead of character.traits.hp.value. This still uses the traitshandler under the hood.

Example:

from evennia.utils import lazy_property
from evennia.contrib.rpg.traits import TraitProperty

class Character(DefaultCharacter):

    strength = TraitProperty(name="STR", trait_type="static", base=10, mod=2)
    hunting = TraitProperty("Hunting Skill", trait_type="counter",
                            base=10, mod=1, max=100)
    health = TraitProperty(trait_type="gauge", min=0, base=100)
Type

Optional extra

health

Allows for applying traits as individual properties directly on the parent class instead for properties on the .traits handler. So with this you could access data e.g. as character.hp.value instead of character.traits.hp.value. This still uses the traitshandler under the hood.

Example:

from evennia.utils import lazy_property
from evennia.contrib.rpg.traits import TraitProperty

class Character(DefaultCharacter):

    strength = TraitProperty(name="STR", trait_type="static", base=10, mod=2)
    hunting = TraitProperty("Hunting Skill", trait_type="counter",
                            base=10, mod=1, max=100)
    health = TraitProperty(trait_type="gauge", min=0, base=100)
Type

Optional extra

class evennia.contrib.rpg.traits.tests.TestTraitFields(methodName='runTest')[source]

Bases: evennia.utils.test_resources.BaseEvenniaTestCase

Test the TraitField class.

test_traitfields()[source]
class evennia.contrib.rpg.traits.tests.TraitContribTestingChar(id, db_key, db_typeclass_path, db_date_created, db_lock_storage, db_account, db_sessid, db_location, db_home, db_destination, db_cmdset_storage)[source]

Bases: evennia.objects.objects.DefaultCharacter

HP

Allows for applying traits as individual properties directly on the parent class instead for properties on the .traits handler. So with this you could access data e.g. as character.hp.value instead of character.traits.hp.value. This still uses the traitshandler under the hood.

Example:

from evennia.utils import lazy_property
from evennia.contrib.rpg.traits import TraitProperty

class Character(DefaultCharacter):

    strength = TraitProperty(name="STR", trait_type="static", base=10, mod=2)
    hunting = TraitProperty("Hunting Skill", trait_type="counter",
                            base=10, mod=1, max=100)
    health = TraitProperty(trait_type="gauge", min=0, base=100)
Type

Optional extra

exception DoesNotExist

Bases: evennia.objects.objects.DefaultCharacter.DoesNotExist

exception MultipleObjectsReturned

Bases: evennia.objects.objects.DefaultCharacter.MultipleObjectsReturned

path = 'evennia.contrib.rpg.traits.tests.TraitContribTestingChar'
typename = 'TraitContribTestingChar'
class evennia.contrib.rpg.traits.tests.TraitPropertyTestCase(methodName='runTest')[source]

Bases: evennia.utils.test_resources.EvenniaTest

Test atomic updating.

character_typeclass

alias of TraitContribTestingChar

test_round1()[source]
test_round2()[source]