evennia.contrib.test_traits
Unit test module for Trait classes.
-
class
evennia.contrib.test_traits.TraitHandlerTest(methodName='runTest')[source]
Bases: evennia.contrib.test_traits._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
-
class
evennia.contrib.test_traits.TestTrait(methodName='runTest')[source]
Bases: evennia.contrib.test_traits._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.test_traits.TestTraitStatic(methodName='runTest')[source]
Bases: evennia.contrib.test_traits._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
-
test_delete()[source]
Deleting resets to default.
-
class
evennia.contrib.test_traits.TestTraitCounter(methodName='runTest')[source]
Bases: evennia.contrib.test_traits._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, 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.test_traits.TestTraitCounterTimed(methodName='runTest')[source]
Bases: evennia.contrib.test_traits._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.test_traits.TestTraitGauge(methodName='runTest')[source]
Bases: evennia.contrib.test_traits._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.test_traits.TestTraitGaugeTimed(methodName='runTest')[source]
Bases: evennia.contrib.test_traits._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.test_traits.TestNumericTraitOperators(methodName='runTest')[source]
Bases: django.test.testcases.TestCase
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.test_traits.DummyCharacter[source]
Bases: evennia.contrib.test_traits._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.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.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.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.test_traits.TestTraitFields(methodName='runTest')[source]
Bases: django.test.testcases.TestCase
Test the TraitField class.
-
test_traitfields()[source]