def make_component(name=None): instance = mock.Mock() instance.session.random.choice = lambda seq: seq[0] component = NamedComponent(name) component.instance = instance component.initialize() return component
def test_reset(): component = make_component() component2 = make_component() assert NamedComponent.names_used == ['Test', 'Test 2'] NamedComponent.reset() assert NamedComponent.names_used == [] assert make_component().name == 'Test'
def _clear_caches(cls): """Clear all data caches in global namespace related to a session""" WorldObject.reset() NamedComponent.reset() AIPlayer.clear_caches() SelectableBuildingComponent.reset()
def tearDown(self): NamedComponent.reset()