Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- (evenv) D:\muddev\hecate>evennia test
- TESTING: Using Evennia's default settings file (evennia.settings_default).
- (use 'evennia test --settings settings.py .' to run only your custom game tests)
- Creating test database for alias 'default'...
- System check identified no issues (0 silenced).
- F.
- ======================================================================
- FAIL: test_equipment_generation (hecate.world.tests.TestEquipmentHandler)
- ----------------------------------------------------------------------
- Traceback (most recent call last):
- File "D:\muddev\hecate\world\tests.py", line 23, in test_equipment_generation
- self.assertDictEqual(equip_dic, actual_dic)
- AssertionError: {'head': None, 'neck': None, 'shoulders': None, 'chest': None, 'arms': None, 'hands': None, 'fingers': None, 'waist': None, 'thighs': None, 'calves': None, 'feet': None, 'inventory_container': a pristine black bag} is not an instance of <class 'dict'> : Second argument is not a dictionary
- ----------------------------------------------------------------------
- Ran 2 tests in 0.989s
- FAILED (failures=1)
- Destroying test database for alias 'default'...
- """
- # tests.py
- class TestEquipmentHandler(EvenniaTest):
- def setUp(self):
- super().setUp()
- self.basic_bag = create.create_object(typeclass='typeclasses.objects.InventoryContainer', key='Basic Bag')
- self.char_test = create.create_object(typeclass='typeclasses.characters.Character', key='Test Char')
- def tearDown(self):
- super().tearDown()
- self.basic_bag.delete()
- self.char_test.delete()
- def test_equipment_generation(self):
- equip_dic = {'head': None, 'neck': None, 'shoulder': None, 'chest': None, 'arms': None, 'hands': None,
- 'fingers': None, 'waist': None, 'thighs': None, 'calves': None, 'feet': None, 'bag': self.basic_bag}
- actual_dic = self.char_test.attributes.get('equipment')
- self.assertDictEqual(equip_dic, actual_dic)
- # equipment_handler.py
- class EquipmentHandler:
- def __init__(self, owner):
- self.owner = owner
- def generate_equipment(self):
- owner = self.owner
- if not owner.attributes.has('equipment'):
- basic_bag = spawn('inventory_bag')
- if basic_bag:
- basic_bag = basic_bag[0]
- basic_bag.move_to(owner)
- equip_dic = {'head': None, 'neck': None, 'shoulders': None, 'chest': None, 'arms': None, 'hands': None,
- 'fingers': None, 'waist': None, 'thighs': None, 'calves': None, 'feet': None, 'inventory_container': basic_bag}
- owner.attributes.add('equipment', equip_dic)
- owner.db.inventory_slots['max_slots'] = basic_bag.db.max_slots
- # prototypes.py
- INVENTORY_CONTAINER = {
- 'prototype_key': 'inventory_container',
- 'key': 'inventory_container',
- 'typeclass': 'typeclasses.objects.InventoryContainer'
- }
- INVENTORY_BAG = {
- 'prototype_parent': 'inventory_container',
- 'key': lambda: generate_random_bag_key()
- }
- def generate_random_bag_key():
- color = ('red', 'blue', 'green', 'yellow', 'black')
- adjective = ('tattered', 'worn', 'pristine', 'well-crafted', 'frayed')
- # a tattered red bag
- # a pristine yellow bag
- bag_key = f"a {random.choice(adjective)} {random.choice(color)} bag"
- return bag_key
- # characters.py
- class Character(DefaultCharacter):
- @lazy_property
- def combat(self):
- return CombatHandler(self)
- @lazy_property
- def equip(self):
- return EquipmentHandler(self)
- def at_object_creation(self):
- self.equip.generate_equipment()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement