diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-08-19 11:00:19 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-08-19 11:00:19 -0400 |
commit | 0e610d6e688e2cedbdbf27771b6a99aebe5b80bd (patch) | |
tree | 8cf15683793887d98ef0c8ff266e4ddb922f488b | |
parent | c2c690ac9add584f2216dc655cdf8215b24ef03c (diff) | |
download | mako-0e610d6e688e2cedbdbf27771b6a99aebe5b80bd.tar.gz |
dont intefere with mako.templates in the test suite
Fixed some issues with running the test suite which would be revealed by
running tests in random order.
Fixes: #338
Change-Id: I90c2a86f9279a265f64b75be3a7af314ab8772ba
-rw-r--r-- | doc/build/unreleased/338.rst | 8 | ||||
-rw-r--r-- | test/module_to_import.py | 2 | ||||
-rw-r--r-- | test/test_template.py | 1 | ||||
-rw-r--r-- | test/test_util.py | 14 |
4 files changed, 18 insertions, 7 deletions
diff --git a/doc/build/unreleased/338.rst b/doc/build/unreleased/338.rst new file mode 100644 index 0000000..8439530 --- /dev/null +++ b/doc/build/unreleased/338.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: bug, tests + :tickets: 338 + + Fixed some issues with running the test suite which would be revealed by + running tests in random order. + + diff --git a/test/module_to_import.py b/test/module_to_import.py new file mode 100644 index 0000000..11ffb98 --- /dev/null +++ b/test/module_to_import.py @@ -0,0 +1,2 @@ +def some_function(): + pass diff --git a/test/test_template.py b/test/test_template.py index 40fd10c..f9727be 100644 --- a/test/test_template.py +++ b/test/test_template.py @@ -1358,6 +1358,7 @@ class GlobalsTest(TemplateTest): class RichTracebackTest(TemplateTest): def _do_test_traceback(self, utf8, memory, syntax): + if memory: if syntax: source = u( diff --git a/test/test_util.py b/test/test_util.py index e40390f..319a8c4 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -43,14 +43,14 @@ class UtilTest(unittest.TestCase): @skip_if(lambda: compat.pypy, "Pypy does this differently") def test_load_module(self): - fn = os.path.join(os.path.dirname(__file__), "test_util.py") - sys.modules.pop("mako.template") - module = compat.load_module("mako.template", fn) - self.assertNotIn("mako.template", sys.modules) - self.assertIn("UtilTest", dir(module)) - import mako.template + path = os.path.join(os.path.dirname(__file__), "module_to_import.py") + some_module = compat.load_module("test.module_to_import", path) + + self.assertNotIn("test.module_to_import", sys.modules) + self.assertIn("some_function", dir(some_module)) + import test.module_to_import - self.assertNotEqual(module, mako.template) + self.assertNotEqual(some_module, test.module_to_import) def test_load_plugin_failure(self): loader = util.PluginLoader("fakegroup") |