evennia.contrib.rpg.traits.tests

Unit test module for Trait classes.

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

基类:evennia.contrib.rpg.traits.tests._TraitHandlerBase

Testing for TraitHandler

setUp()[源代码]

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

test_add_trait()[源代码]
test_cache()[源代码]

Cache should not be set until first get

test_setting()[源代码]

Don’t allow setting stuff on traithandler

test_getting()[源代码]

Test we are getting data from the dbstore

test_all()[源代码]

Test all method

test_remove()[源代码]

Test remove method

test_clear()[源代码]

Test clear method

test_trait_db_connection()[源代码]

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')[源代码]

基类:evennia.contrib.rpg.traits.tests._TraitHandlerBase

Test the base Trait class

setUp()[源代码]

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

test_init()[源代码]
test_validate_input__valid()[源代码]

Test valid validation input

test_validate_input__fail()[源代码]

Test failing validation

test_trait_getset()[源代码]

Get-set-del operations on trait

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

基类:evennia.contrib.rpg.traits.tests._TraitHandlerBase

Test for static Traits

setUp()[源代码]

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

test_init()[源代码]
test_value()[源代码]

value is (base + mod) * mult

test_delete()[源代码]

Deleting resets to default.

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

基类:evennia.contrib.rpg.traits.tests._TraitHandlerBase

Test for counter- Traits

setUp()[源代码]

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

test_init()[源代码]
test_value()[源代码]

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

test_boundaries__minmax()[源代码]

Test range

test_boundaries__bigmod()[源代码]

add a big mod

test_boundaries__change_boundaries()[源代码]

Change boundaries after base/mod change

test_boundaries__disable()[源代码]

Disable and re-enable boundaries

test_boundaries__inverse()[源代码]

Set inverse boundaries - limited by base

test_current()[源代码]

Modifying current value

test_delete()[源代码]

Deleting resets to default.

test_percentage()[源代码]

Test percentage calculation

test_descs()[源代码]

Test descriptions

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

基类:evennia.contrib.rpg.traits.tests._TraitHandlerBase

Test for trait with timer component

setUp()[源代码]

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

test_timer_rate(mock_time)[源代码]

Test time stepping

test_timer_ratetarget(mock_time)[源代码]

test ratetarget

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

基类:evennia.contrib.rpg.traits.tests._TraitHandlerBase

setUp()[源代码]

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

test_init()[源代码]
test_value()[源代码]

value is current, where current defaults to base + mod

test_boundaries__minmax()[源代码]

Test range

test_boundaries__bigmod()[源代码]

add a big mod

test_boundaries__change_boundaries()[源代码]

Change boundaries after current change

test_boundaries__disable()[源代码]

Disable and re-enable boundary

test_boundaries__inverse()[源代码]

Try to set reversed boundaries

test_current()[源代码]

Modifying current value

test_delete()[源代码]

Deleting resets to default.

test_percentage()[源代码]

Test percentage calculation

test_descs()[源代码]

Test descriptions

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

基类:evennia.contrib.rpg.traits.tests._TraitHandlerBase

Test for trait with timer component

setUp()[源代码]

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

test_timer_rate(mock_time)[源代码]

Test time stepping

test_timer_ratetarget(mock_time)[源代码]

test ratetarget

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

基类:evennia.utils.test_resources.BaseEvenniaTestCase

Test case for numeric magic method implementations.

setUp()[源代码]

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

tearDown()[源代码]

Hook method for deconstructing the test fixture after testing it.

test_pos_shortcut()[源代码]

overridden unary + operator returns value property

test_add_traits()[源代码]

test addition of Trait objects

test_sub_traits()[源代码]

test subtraction of Trait objects

test_mul_traits()[源代码]

test multiplication of Trait objects

test_floordiv()[源代码]

test floor division of Trait objects

test_comparisons_traits()[源代码]

test equality comparison between Trait objects

test_comparisons_numeric()[源代码]

equality comparisons between Trait and numeric

class evennia.contrib.rpg.traits.tests.DummyCharacter[源代码]

基类: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')[源代码]

基类:evennia.utils.test_resources.BaseEvenniaTestCase

Test the TraitField class.

test_traitfields()[源代码]
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)[源代码]

基类: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

基类:evennia.objects.objects.DefaultCharacter.DoesNotExist

exception MultipleObjectsReturned

基类:evennia.objects.objects.DefaultCharacter.MultipleObjectsReturned

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

基类:evennia.utils.test_resources.EvenniaTest

Test atomic updating.

character_typeclass

TraitContribTestingChar 的别名

test_round1()[源代码]
test_round2()[源代码]