Kaydet (Commit) d3e83e2a authored tarafından Nick Coghlan's avatar Nick Coghlan

Avoid global side effect in test_ensurepip

üst ca351e6b
...@@ -2,6 +2,8 @@ import unittest ...@@ -2,6 +2,8 @@ import unittest
import unittest.mock import unittest.mock
import ensurepip import ensurepip
import test.support import test.support
import os
import os.path
class TestEnsurePipVersion(unittest.TestCase): class TestEnsurePipVersion(unittest.TestCase):
...@@ -17,9 +19,12 @@ class TestBootstrap(unittest.TestCase): ...@@ -17,9 +19,12 @@ class TestBootstrap(unittest.TestCase):
self.run_pip = run_pip_patch.start() self.run_pip = run_pip_patch.start()
self.addCleanup(run_pip_patch.stop) self.addCleanup(run_pip_patch.stop)
os_environ_patch = unittest.mock.patch("ensurepip.os.environ", {}) # Avoid side effects on the actual os module
self.os_environ = os_environ_patch.start() os_patch = unittest.mock.patch("ensurepip.os")
self.addCleanup(os_environ_patch.stop) 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): def test_basic_bootstrapping(self):
ensurepip.bootstrap() ensurepip.bootstrap()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment