add test for un-startable script
This commit is contained in:
parent
2e9971dc82
commit
77eccd3033
1 changed files with 54 additions and 42 deletions
|
|
@ -11,6 +11,9 @@ _BASE_TYPECLASS = class_from_module(settings.BASE_SCRIPT_TYPECLASS)
|
||||||
class GoodScript(DefaultScript):
|
class GoodScript(DefaultScript):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class InvalidScript:
|
||||||
|
pass
|
||||||
|
|
||||||
class BrokenScript(DefaultScript):
|
class BrokenScript(DefaultScript):
|
||||||
"""objects will fail upon call"""
|
"""objects will fail upon call"""
|
||||||
@property
|
@property
|
||||||
|
|
@ -64,9 +67,18 @@ class TestGlobalScriptContainer(unittest.TestCase):
|
||||||
self.assertIn('script_name', gsc.typeclass_storage)
|
self.assertIn('script_name', gsc.typeclass_storage)
|
||||||
self.assertEqual(gsc.typeclass_storage['script_name'], GoodScript)
|
self.assertEqual(gsc.typeclass_storage['script_name'], GoodScript)
|
||||||
|
|
||||||
@override_settings(GLOBAL_SCRIPTS={'script_name': {'typeclass': 'evennia.utils.tests.test_containers.BrokenScript'}})
|
@override_settings(GLOBAL_SCRIPTS={'script_name': {'typeclass': 'evennia.utils.tests.test_containers.InvalidScript'}})
|
||||||
def test_start_with_broken_script(self):
|
def test_start_with_invalid_script(self):
|
||||||
"""Broken script module should traceback"""
|
"""Script class doesn't implement required start methods"""
|
||||||
|
gsc = containers.GlobalScriptContainer()
|
||||||
|
|
||||||
|
with self.assertRaises(Exception) as cm:
|
||||||
|
gsc.start()
|
||||||
|
self.fail("An exception was expected but it didn't occur.")
|
||||||
|
|
||||||
|
@override_settings(GLOBAL_SCRIPTS={'script_name': {'typeclass': 'evennia.utils.tests.test_containers.BrokenScript'}})
|
||||||
|
def test_start_with_broken_script(self):
|
||||||
|
"""Un-importable script should traceback"""
|
||||||
gsc = containers.GlobalScriptContainer()
|
gsc = containers.GlobalScriptContainer()
|
||||||
|
|
||||||
with self.assertRaises(Exception) as cm:
|
with self.assertRaises(Exception) as cm:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue