aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-01-03 03:07:13 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-01-03 03:07:13 -0500
commit1434374b64408c1a21ce75de662ca2a65e72ab1c (patch)
tree1ce68fb39055eee5d6fac6df342365fb9ed1eacc /setuptools/tests
parentf74153cd1cfee6bef9a8628937fa2eee7d2da4c5 (diff)
downloadexternal_python_setuptools-1434374b64408c1a21ce75de662ca2a65e72ab1c.tar.gz
external_python_setuptools-1434374b64408c1a21ce75de662ca2a65e72ab1c.tar.bz2
external_python_setuptools-1434374b64408c1a21ce75de662ca2a65e72ab1c.zip
Use mock to patch sys.modules
Diffstat (limited to 'setuptools/tests')
-rw-r--r--setuptools/tests/test_easy_install.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index 834b83e4..a27fef13 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -447,15 +447,9 @@ class TestScriptHeader:
compat.PY3 and os.environ.get("LC_CTYPE") in ("C", "POSIX"),
reason="Test fails in this locale on Python 3"
)
+ @mock.patch.dict(sys.modules, java=mock.Mock(lang=mock.Mock(System=
+ mock.Mock(getProperty=mock.Mock(return_value="")))))
def test_get_script_header_jython_workaround(self):
- class java:
- class lang:
- class System:
- @staticmethod
- def getProperty(property):
- return ""
- sys.modules["java"] = java
-
platform = sys.platform
sys.platform = 'java1.5.0_13'
stdout, stderr = sys.stdout, sys.stderr
@@ -481,6 +475,5 @@ class TestScriptHeader:
assert candidate == '#!%s -x\n' % self.non_ascii_exe
assert 'Unable to adapt shebang line' in sys.stdout.getvalue()
finally:
- del sys.modules["java"]
sys.platform = platform
sys.stdout, sys.stderr = stdout, stderr