From 33da3d803182c2aa89e98ac41a5cc5275b7a5264 Mon Sep 17 00:00:00 2001 From: Bradley Marques Date: Fri, 21 Apr 2023 22:00:42 +0200 Subject: [PATCH 1/2] Adds tearDown() to flush id cache --- evennia/utils/test_resources.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/evennia/utils/test_resources.py b/evennia/utils/test_resources.py index 158a940ee..4e05499ee 100644 --- a/evennia/utils/test_resources.py +++ b/evennia/utils/test_resources.py @@ -558,9 +558,19 @@ class EvenniaTestCase(TestCase): """ For use with gamedir settings; Just like the normal test case, only for naming consistency. + Notes: + + - Inheriting from this class will bypass EvenniaTestMixin, and therefore + not setup some default objects. This can result in faster tests. + + - If you do inherit from this class for your unit tests, and have + overridden the tearDown() method, please also call flush_cache(). Not + doing so will result in flakey and order-dependent tests due to the + Django ID cache not being flushed. """ - pass + def tearDown(self) -> None: + flush_cache() @override_settings(**DEFAULT_SETTINGS) From 36bdfad772d9ce16031bcdd2d4f085e28de1cfd4 Mon Sep 17 00:00:00 2001 From: Bradley Marques Date: Fri, 21 Apr 2023 22:01:42 +0200 Subject: [PATCH 2/2] Fixes typo --- docs/source/Coding/Unit-Testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/Coding/Unit-Testing.md b/docs/source/Coding/Unit-Testing.md index ce47c2452..b4825a3c4 100644 --- a/docs/source/Coding/Unit-Testing.md +++ b/docs/source/Coding/Unit-Testing.md @@ -106,7 +106,7 @@ To test this, run to run the entire test module - evennia test --settings setings.py world.tests + evennia test --settings settings.py world.tests or a specific class: