diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2022-08-04 17:18:11 +0200 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2022-08-04 17:18:11 +0200 |
commit | 1fe460ea2d1339358ea9cd4c909151ed7eccdcfc (patch) | |
tree | d5b40a203f9d194c2eddd67b966535efc8ef6325 /tests | |
parent | 0c86939154a29d14a2c6e44e472bed016ace4651 (diff) |
Explicitely close another missing temporary directory
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_commands.py | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/tests/test_commands.py b/tests/test_commands.py index 9cd5c88..d52908a 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -145,27 +145,27 @@ class testCommandsSimple(unittest.TestCase, CommandsMixin): self.assertEqual(streams['stderr'].getvalue(), '') def test_export(self): - dest_tmpdir = tempfile.TemporaryDirectory() - utils.copytree( - 'tests/data/simple', - dest_tmpdir.name, - dirs_exist_ok=True, - ) - # TODO: make finding the templates less prone to breaking and - # then remove the cwd change from here - old_cwd = os.getcwd() - os.chdir(self.tmpdir.name) - args = { - 'collection': self.tmpdir.name, - 'git': True, - 'template': 'templates/from_self.yaml', - 'query': 'Another', - 'destination': dest_tmpdir.name, - } - streams = self._run_command(command.Export(), args) - os.chdir(old_cwd) - self.assertEqual(streams['stdout'].getvalue(), '') - self.assertEqual(streams['stderr'].getvalue(), '') + with tempfile.TemporaryDirectory() as dest_tmpdir: + utils.copytree( + 'tests/data/simple', + dest_tmpdir, + dirs_exist_ok=True, + ) + # TODO: make finding the templates less prone to breaking and + # then remove the cwd change from here + old_cwd = os.getcwd() + os.chdir(self.tmpdir.name) + args = { + 'collection': self.tmpdir.name, + 'git': True, + 'template': 'templates/from_self.yaml', + 'query': 'Another', + 'destination': dest_tmpdir, + } + streams = self._run_command(command.Export(), args) + os.chdir(old_cwd) + self.assertEqual(streams['stdout'].getvalue(), '') + self.assertEqual(streams['stderr'].getvalue(), '') def test_remove(self): args = { |