diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2013-11-13 12:24:58 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2013-11-13 12:24:58 (GMT) |
commit | d3e83e2a3e88cc424d14d9aaff09d03feed1a10f (patch) | |
tree | eba72bea2f8a85101132b944e2699eaadf9ed4fc /Lib/test/test_ensurepip.py | |
parent | ca351e6bc5421b1cc3d3d3e17fb762bdd7139ea4 (diff) | |
download | cpython-d3e83e2a3e88cc424d14d9aaff09d03feed1a10f.zip cpython-d3e83e2a3e88cc424d14d9aaff09d03feed1a10f.tar.gz cpython-d3e83e2a3e88cc424d14d9aaff09d03feed1a10f.tar.bz2 |
Avoid global side effect in test_ensurepip
Diffstat (limited to 'Lib/test/test_ensurepip.py')
-rw-r--r-- | Lib/test/test_ensurepip.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/test/test_ensurepip.py b/Lib/test/test_ensurepip.py index e87f476..abf00fd 100644 --- a/Lib/test/test_ensurepip.py +++ b/Lib/test/test_ensurepip.py @@ -2,6 +2,8 @@ import unittest import unittest.mock import ensurepip import test.support +import os +import os.path class TestEnsurePipVersion(unittest.TestCase): @@ -17,9 +19,12 @@ class TestBootstrap(unittest.TestCase): self.run_pip = run_pip_patch.start() self.addCleanup(run_pip_patch.stop) - os_environ_patch = unittest.mock.patch("ensurepip.os.environ", {}) - self.os_environ = os_environ_patch.start() - self.addCleanup(os_environ_patch.stop) + # Avoid side effects on the actual os module + os_patch = unittest.mock.patch("ensurepip.os") + patched_os = os_patch.start() + self.addCleanup(os_patch.stop) + patched_os.path = os.path + self.os_environ = patched_os.environ = os.environ.copy() def test_basic_bootstrapping(self): ensurepip.bootstrap() |