Fix or noqa B003 (assigning to os.environ doesn't do what you expect)

Signed-off-by: Aarni Koskela <akx@iki.fi>
This commit is contained in:
Aarni Koskela 2023-05-11 16:22:43 +03:00
parent c4b5cc3629
commit 86d47b8914
3 changed files with 5 additions and 3 deletions

View File

@ -7,7 +7,7 @@ from unittest import mock
@mock.patch.dict(os.environ) @mock.patch.dict(os.environ)
def test_create_environment_dict(): def test_create_environment_dict():
base = {'FOO': 'bar', 'BAZ': 'foobar'} base = {'FOO': 'bar', 'BAZ': 'foobar'}
os.environ = base os.environ = base # noqa: B003
assert create_environment_dict({'FOO': 'baz'}) == { assert create_environment_dict({'FOO': 'baz'}) == {
'FOO': 'baz', 'BAZ': 'foobar', 'FOO': 'baz', 'BAZ': 'foobar',
} }

View File

@ -153,7 +153,8 @@ class FromEnvTest(unittest.TestCase):
self.os_environ = os.environ.copy() self.os_environ = os.environ.copy()
def tearDown(self): def tearDown(self):
os.environ = self.os_environ os.environ.clear()
os.environ.update(self.os_environ)
def test_from_env(self): def test_from_env(self):
"""Test that environment variables are passed through to """Test that environment variables are passed through to

View File

@ -59,7 +59,8 @@ class KwargsFromEnvTest(unittest.TestCase):
self.os_environ = os.environ.copy() self.os_environ = os.environ.copy()
def tearDown(self): def tearDown(self):
os.environ = self.os_environ os.environ.clear()
os.environ.update(self.os_environ)
def test_kwargs_from_env_empty(self): def test_kwargs_from_env_empty(self):
os.environ.update(DOCKER_HOST='', os.environ.update(DOCKER_HOST='',