mirror of
https://github.com/adrienverge/yamllint.git
synced 2025-02-25 18:55:20 -06:00
tests: Don’t bother restoring HOME
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]: <https://stackoverflow.com/q/716011/7593853>
This commit is contained in:
parent
152ba20f33
commit
f3adc585d2
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user