summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-01-14 13:22:36 -0500
committerNed Batchelder <ned@nedbatchelder.com>2017-01-14 13:22:36 -0500
commit04beb40df71bd0c3774f44016bfc85389319ef7f (patch)
tree6e38fa1a45d15d13fb703e7e41c313734dc230a1
parentef13e807a709ad0cda9c0f51b4e43894dc735ecb (diff)
downloadpython-coveragepy-git-04beb40df71bd0c3774f44016bfc85389319ef7f.tar.gz
More Jython test fixes/skips
-rw-r--r--tests/coveragetest.py8
-rw-r--r--tests/modules/process_test/try_execfile.py8
-rw-r--r--tests/test_arcs.py3
-rw-r--r--tests/test_process.py15
4 files changed, 31 insertions, 3 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index a98462c4..d13f2bbb 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -411,13 +411,17 @@ class CoverageTest(
# Add our test modules directory to PYTHONPATH. I'm sure there's too
# much path munging here, but...
+ pythonpath_name = "PYTHONPATH"
+ if env.JYTHON:
+ pythonpath_name = "JYTHONPATH"
+
testmods = self.nice_file(self.working_root(), 'tests/modules')
zipfile = self.nice_file(self.working_root(), 'tests/zipmods.zip')
- pypath = os.getenv('PYTHONPATH', '')
+ pypath = os.getenv(pythonpath_name, '')
if pypath:
pypath += os.pathsep
pypath += testmods + os.pathsep + zipfile
- self.set_environ('PYTHONPATH', pypath)
+ self.set_environ(pythonpath_name, pypath)
self.last_command_status, self.last_command_output = run_command(cmd)
print(self.last_command_output)
diff --git a/tests/modules/process_test/try_execfile.py b/tests/modules/process_test/try_execfile.py
index 70905071..03742512 100644
--- a/tests/modules/process_test/try_execfile.py
+++ b/tests/modules/process_test/try_execfile.py
@@ -50,6 +50,8 @@ def without_same_files(filenames):
reduced.append(filename)
return reduced
+skips = os.getenv('COVERAGE_TRY_EXECFILE_SKIPS', '').split()
+
cleaned_sys_path = [os.path.normcase(p) for p in without_same_files(sys.path)]
DATA = "xyzzy"
@@ -65,6 +67,10 @@ FN_VAL = my_function("fooey")
loader = globals().get('__loader__')
fullname = getattr(loader, 'fullname', None) or getattr(loader, 'name', None)
+argv = sys.argv
+if 'argv0' in skips:
+ argv[0] = '*skipped*'
+
globals_to_check = {
'__name__': __name__,
'__file__': __file__,
@@ -77,7 +83,7 @@ globals_to_check = {
'DATA': DATA,
'FN_VAL': FN_VAL,
'__main__.DATA': getattr(__main__, "DATA", "nothing"),
- 'argv': sys.argv,
+ 'argv': argv,
'path': cleaned_sys_path,
}
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index d9b77dce..eaa57e66 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -1101,6 +1101,9 @@ class MiscArcTest(CoverageTest):
)
def test_pathologically_long_code_object(self):
+ if env.JYTHON:
+ self.skipTest("Bytecode concerns are irrelevant on Jython")
+
# https://bitbucket.org/ned/coveragepy/issue/359
# The structure of this file is such that an EXTENDED_ARG bytecode is
# needed to encode the jump at the end. We weren't interpreting those
diff --git a/tests/test_process.py b/tests/test_process.py
index be9bdb76..0bf2a7a5 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -460,6 +460,11 @@ class ProcessTest(CoverageTest):
def test_coverage_run_dir_is_like_python_dir(self):
with open(TRY_EXECFILE) as f:
self.make_file("with_main/__main__.py", f.read())
+
+ if env.JYTHON:
+ # Jython has a different sys.argv[0].
+ self.set_environ("COVERAGE_TRY_EXECFILE_SKIPS", "argv0")
+
out_cov = self.run_command("coverage run with_main")
out_py = self.run_command("python with_main")
@@ -533,6 +538,11 @@ class ProcessTest(CoverageTest):
self.make_file("sub/__init__.py", "")
with open(TRY_EXECFILE) as f:
self.make_file("sub/run_me.py", f.read())
+
+ if env.JYTHON:
+ # Jython has a different sys.argv[0].
+ self.set_environ("COVERAGE_TRY_EXECFILE_SKIPS", "argv0")
+
out_cov = self.run_command("coverage run -m sub.run_me")
out_py = self.run_command("python -m sub.run_me")
self.assertMultiLineEqual(out_cov, out_py)
@@ -873,6 +883,11 @@ class AliasedCommandTest(CoverageTest):
run_in_temp_dir = False
+ def setUp(self):
+ super(AliasedCommandTest, self).setUp()
+ if env.JYTHON:
+ self.skipTest("Coverage command names don't work on Jython")
+
def test_major_version_works(self):
# "coverage2" works on py2
cmd = "coverage%d" % sys.version_info[0]