diff options
| -rw-r--r-- | src/mailman/config/tests/test_configuration.py | 4 | ||||
| -rw-r--r-- | src/mailman/testing/layers.py | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/mailman/config/tests/test_configuration.py b/src/mailman/config/tests/test_configuration.py index a64b85ca0..f295ef633 100644 --- a/src/mailman/config/tests/test_configuration.py +++ b/src/mailman/config/tests/test_configuration.py @@ -18,6 +18,7 @@ """Test the system-wide global configuration.""" import os +import shutil import unittest from contextlib import ExitStack @@ -51,6 +52,9 @@ class TestConfiguration(unittest.TestCase): self.assertEqual(events, ['first', 'second', 'first']) def test_config_template_dir_is_source(self): + # This test will leave a 'var' directory in the top-level source + # directory. Be sure to clean it up. + self.addCleanup(shutil.rmtree, 'var') config = Configuration() with NamedTemporaryFile('w', encoding='utf-8') as fp: print("""\ diff --git a/src/mailman/testing/layers.py b/src/mailman/testing/layers.py index c282689d1..3c65d0b2a 100644 --- a/src/mailman/testing/layers.py +++ b/src/mailman/testing/layers.py @@ -184,8 +184,12 @@ class ConfigLayer(MockAndMonkeyLayer): # Destroy the test database after the tests are done so that there is # no data in case the tests are rerun with a database layer like mysql # or postgresql which are not deleted in teardown. - config.pop('test config') shutil.rmtree(cls.var_dir) + config.pop('test config') + # Now config.VAR_DIR will point to the current directory's 'var' + # directory, which will have been created in config.pop()'s post + # processing. Clean that up too. + shutil.rmtree(config.VAR_DIR, ignore_errors=True) cls.var_dir = None @classmethod |
