From f3adc585d2f9b10211f06b277b6914422f419ec8 Mon Sep 17 00:00:00 2001 From: Jason Yundt Date: Sat, 30 Dec 2023 14:22:49 -0500 Subject: [PATCH] =?UTF-8?q?tests:=20Don=E2=80=99t=20bother=20restoring=20H?= =?UTF-8?q?OME?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some unittests set environment variables, but then delete them as part of their cleanup process. Deleting them is OK. Any test that needs an environment variable should set that environment variable itself. Once the test process stops, any changes made to the environment will be lost [1]. Before this change, there was one location where an environment variable was restored to its original value instead of deleted. Restoring that variable was unnecessary. This commit was created to prepare for a future commit which will delete HOME before any of the tests even start. Without this change, that future change would crash. You can’t restore a variable that’s been deleted. Fixes #605. [1]: --- tests/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 28a0599..5301515 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -315,7 +315,7 @@ class CommandLineTestCase(unittest.TestCase): os.makedirs(dir) config = os.path.join(dir, 'config') - self.addCleanup(os.environ.update, HOME=os.environ['HOME']) + self.addCleanup(os.environ.__delitem__, 'HOME') os.environ['HOME'] = home with open(config, 'w') as f: