diff options
-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 = { |