summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-12-30 18:07:36 -0500
committerNed Batchelder <ned@nedbatchelder.com>2022-12-30 18:35:09 -0500
commit45787e29dea3a41f2e9570b66a571a7ebcda4592 (patch)
tree7eeadde7d7a033e27abd1df7411bb525bd711148 /tests
parent85c7a4ac4161c4eb2efeaf07e6f833d3a073b018 (diff)
downloadpython-coveragepy-git-45787e29dea3a41f2e9570b66a571a7ebcda4592.tar.gz
refactor: removed mentions of Jython and IronPython
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py9
-rw-r--r--tests/coveragetest.py20
-rw-r--r--tests/test_arcs.py6
-rw-r--r--tests/test_cmdline.py2
-rw-r--r--tests/test_concurrency.py16
-rw-r--r--tests/test_execfile.py4
-rw-r--r--tests/test_oddball.py9
-rw-r--r--tests/test_process.py22
-rw-r--r--tests/test_python.py4
-rw-r--r--tests/test_summary.py8
10 files changed, 13 insertions, 87 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 600ada44..d45cae1d 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -16,7 +16,6 @@ from pathlib import Path
import pytest
from coverage import env
-from coverage.exceptions import _StopEverything
from coverage.files import set_relative_directory
# Pytest will rewrite assertions in test modules, but not elsewhere.
@@ -106,14 +105,6 @@ def pytest_sessionfinish():
if pth_file.exists():
pth_file.unlink()
-@pytest.hookimpl(hookwrapper=True)
-def pytest_runtest_call(item):
- """Run once for each test."""
- # Convert _StopEverything into skipped tests.
- outcome = yield
- if outcome.excinfo and issubclass(outcome.excinfo[0], _StopEverything): # pragma: only jython
- pytest.skip(f"Skipping {item.nodeid} for _StopEverything: {outcome.excinfo[1]}")
-
def possible_pth_dirs():
"""Produce a sequence of directories for trying to write .pth files."""
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index 56e78853..e718dd31 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -15,10 +15,7 @@ import re
import shlex
import sys
-import pytest
-
import coverage
-from coverage import env
from coverage.cmdline import CoverageScript
from coverage.misc import import_local_file
@@ -386,18 +383,9 @@ class CoverageTest(
command_words = [os.path.basename(sys.executable)]
elif command_name == "coverage":
- if env.JYTHON: # pragma: only jython
- # Jython can't do reporting, so let's skip the test now.
- if command_args and command_args[0] in ('report', 'html', 'xml', 'annotate'):
- pytest.skip("Can't run reporting commands in Jython")
- # Jython can't run "coverage" as a command because the shebang
- # refers to another shebang'd Python script. So run them as
- # modules.
- command_words = "jython -m coverage".split()
- else:
- # The invocation requests the coverage.py program. Substitute the
- # actual coverage.py main command name.
- command_words = [self.coverage_command]
+ # The invocation requests the coverage.py program. Substitute the
+ # actual coverage.py main command name.
+ command_words = [self.coverage_command]
else:
command_words = [command_name]
@@ -407,8 +395,6 @@ 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" # pragma: only jython
testmods = nice_file(self.working_root(), "tests/modules")
zipfile = nice_file(self.working_root(), "tests/zipmods.zip")
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 1d20470f..4c68abba 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -157,13 +157,9 @@ class SimpleArcTest(CoverageTest):
)
def test_what_is_the_sound_of_no_lines_clapping(self):
- if env.JYTHON:
- # Jython reports no lines for an empty file.
- arcz_missing=".1 1." # pragma: only jython
- elif env.PYBEHAVIOR.empty_is_empty:
+ if env.PYBEHAVIOR.empty_is_empty:
arcz_missing=".1 1."
else:
- # Other Pythons report one line.
arcz_missing=""
self.check_coverage("""\
# __init__.py
diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py
index 96e7ffb9..67899b75 100644
--- a/tests/test_cmdline.py
+++ b/tests/test_cmdline.py
@@ -977,7 +977,6 @@ class CmdLineStdoutTest(BaseCmdLineTest):
assert "without C extension" in out
assert out.count("\n") < 4
- @pytest.mark.skipif(env.JYTHON, reason="Jython gets mad if you patch sys.argv")
def test_help_contains_command_name(self):
# Command name should be present in help output.
fake_command_path = os_sep("lorem/ipsum/dolor")
@@ -988,7 +987,6 @@ class CmdLineStdoutTest(BaseCmdLineTest):
out = self.stdout()
assert expected_command_name in out
- @pytest.mark.skipif(env.JYTHON, reason="Jython gets mad if you patch sys.argv")
def test_help_contains_command_name_from_package(self):
# Command package name should be present in help output.
#
diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py
index 2c827760..8dea0a44 100644
--- a/tests/test_concurrency.py
+++ b/tests/test_concurrency.py
@@ -4,6 +4,7 @@
"""Tests for concurrency libraries."""
import glob
+import multiprocessing
import os
import random
import re
@@ -12,6 +13,7 @@ import threading
import time
from flaky import flaky
+import greenlet
import pytest
import coverage
@@ -27,11 +29,6 @@ from tests.coveragetest import CoverageTest
# These libraries aren't always available, we'll skip tests if they aren't.
try:
- import multiprocessing
-except ImportError: # pragma: only jython
- multiprocessing = None
-
-try:
import eventlet
except ImportError:
eventlet = None
@@ -41,11 +38,6 @@ try:
except ImportError:
gevent = None
-try:
- import greenlet
-except ImportError: # pragma: only jython
- greenlet = None
-
def measurable_line(l):
"""Is this a line of code coverage will measure?
@@ -59,9 +51,6 @@ def measurable_line(l):
return False
if l.startswith('else:'):
return False
- if env.JYTHON and l.startswith(('try:', 'except:', 'except ', 'break', 'with ')):
- # Jython doesn't measure these statements.
- return False # pragma: only jython
return True
@@ -443,7 +432,6 @@ def start_method_fixture(request):
return start_method
-@pytest.mark.skipif(not multiprocessing, reason="No multiprocessing in this Python")
@flaky(max_runs=30) # Sometimes a test fails due to inherent randomness. Try more times.
class MultiprocessingTest(CoverageTest):
"""Test support of the multiprocessing module."""
diff --git a/tests/test_execfile.py b/tests/test_execfile.py
index 329ec528..e1db7bb5 100644
--- a/tests/test_execfile.py
+++ b/tests/test_execfile.py
@@ -14,7 +14,6 @@ import sys
import pytest
-from coverage import env
from coverage.exceptions import NoCode, NoSource, _ExceptionDuringRun
from coverage.execfile import run_python_file, run_python_module
from coverage.files import python_reported_file
@@ -196,9 +195,6 @@ class RunPycFileTest(CoverageTest):
def make_pyc(self, **kwargs):
"""Create a .pyc file, and return the path to it."""
- if env.JYTHON:
- pytest.skip("Can't make .pyc files on Jython")
-
self.make_file("compiled.py", """\
def doit():
print("I am here!")
diff --git a/tests/test_oddball.py b/tests/test_oddball.py
index 15dae128..37216b39 100644
--- a/tests/test_oddball.py
+++ b/tests/test_oddball.py
@@ -155,7 +155,6 @@ class MemoryLeakTest(CoverageTest):
"""
@flaky
- @pytest.mark.skipif(env.JYTHON, reason="Don't bother on Jython")
@pytest.mark.skipif(not env.C_TRACER, reason="Only the C tracer has refcounting issues")
def test_for_leaks(self):
# Our original bad memory leak only happened on line numbers > 255, so
@@ -235,7 +234,6 @@ class MemoryFumblingTest(CoverageTest):
assert "Fatal" not in out
-@pytest.mark.skipif(env.JYTHON, reason="Pyexpat isn't a problem on Jython")
class PyexpatTest(CoverageTest):
"""Pyexpat screws up tracing. Make sure we've counter-defended properly."""
@@ -388,13 +386,6 @@ class ExceptionTest(CoverageTest):
lines = data.lines(abs_file(filename))
clean_lines[filename] = sorted(lines)
- if env.JYTHON: # pragma: only jython
- # Jython doesn't report on try or except lines, so take those
- # out of the expected lines.
- invisible = [202, 206, 302, 304]
- for lines in lines_expected.values():
- lines[:] = [l for l in lines if l not in invisible]
-
assert clean_lines == lines_expected
diff --git a/tests/test_process.py b/tests/test_process.py
index 3324497d..33d52923 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -578,8 +578,6 @@ class ProcessTest(CoverageTest):
# Pypy passes locally, but fails in CI? Perhaps the version of macOS is
# significant? https://foss.heptapod.net/pypy/pypy/-/issues/3074
@pytest.mark.skipif(env.PYPY, reason="PyPy is unreliable with this test")
- # Jython as of 2.7.1rc3 won't compile a filename that isn't utf-8.
- @pytest.mark.skipif(env.JYTHON, reason="Jython can't handle this test")
def test_lang_c(self):
# LANG=C forces getfilesystemencoding on Linux to 'ascii', which causes
# failures with non-ascii file names. We don't want to make a real file
@@ -669,12 +667,6 @@ class EnvironmentTest(CoverageTest):
"""
# First, is this even credible try_execfile.py output?
assert '"DATA": "xyzzy"' in actual
-
- if env.JYTHON: # pragma: only jython
- # Argv0 is different for Jython, remove that from the comparison.
- expected = re_lines_text(r'\s+"argv0":', expected, match=False)
- actual = re_lines_text(r'\s+"argv0":', actual, match=False)
-
assert actual == expected
def test_coverage_run_is_like_python(self):
@@ -906,10 +898,8 @@ class ExcepthookTest(CoverageTest):
""")
cov_st, cov_out = self.run_command_status("coverage run excepthook.py")
py_st, py_out = self.run_command_status("python excepthook.py")
- if not env.JYTHON:
- assert cov_st == py_st
- assert cov_st == 1
-
+ assert cov_st == py_st
+ assert cov_st == 1
assert "in excepthook" in py_out
assert cov_out == py_out
@@ -960,15 +950,12 @@ class ExcepthookTest(CoverageTest):
""")
cov_st, cov_out = self.run_command_status("coverage run excepthook_throw.py")
py_st, py_out = self.run_command_status("python excepthook_throw.py")
- if not env.JYTHON:
- assert cov_st == py_st
- assert cov_st == 1
-
+ assert cov_st == py_st
+ assert cov_st == 1
assert "in excepthook" in py_out
assert cov_out == py_out
-@pytest.mark.skipif(env.JYTHON, reason="Coverage command names don't work on Jython")
class AliasedCommandTest(CoverageTest):
"""Tests of the version-specific command aliases."""
@@ -1261,7 +1248,6 @@ class ProcessStartupWithSourceTest(CoverageTest):
self.make_file(path("__init__.py"), "")
# sub.py will write a few lines.
self.make_file(path("sub.py"), """\
- # Avoid 'with' so Jython can play along.
f = open("out.txt", "w")
f.write("Hello, world!")
f.close()
diff --git a/tests/test_python.py b/tests/test_python.py
index a8288613..fd8e7b52 100644
--- a/tests/test_python.py
+++ b/tests/test_python.py
@@ -59,7 +59,3 @@ def test_source_for_file_windows(tmpdir):
# If both pyw and py exist, py is preferred
path.ensure(file=True)
assert source_for_file(src + 'c') == src
-
-
-def test_source_for_file_jython():
- assert source_for_file("a$py.class") == "a.py"
diff --git a/tests/test_summary.py b/tests/test_summary.py
index f0f16aa2..45427079 100644
--- a/tests/test_summary.py
+++ b/tests/test_summary.py
@@ -614,7 +614,6 @@ class SummaryTest(UsingModulesMixin, CoverageTest):
output = self.get_report(cov, squeeze=False)
assert output == report_expected
- @pytest.mark.skipif(env.JYTHON, reason="Jython doesn't like accented file names")
def test_accenteddotpy_not_python(self):
# We run a .py file with a non-ascii name, and when reporting, we can't
# parse it as Python. We should get an error message in the report.
@@ -779,10 +778,9 @@ class SummaryTest(UsingModulesMixin, CoverageTest):
# Python 3 puts the .pyc files in a __pycache__ directory, and will
# not import from there without source. It will import a .pyc from
# the source location though.
- if not env.JYTHON:
- pycs = glob.glob("__pycache__/mod.*.pyc")
- assert len(pycs) == 1
- os.rename(pycs[0], "mod.pyc")
+ pycs = glob.glob("__pycache__/mod.*.pyc")
+ assert len(pycs) == 1
+ os.rename(pycs[0], "mod.pyc")
# Run the program.
cov = coverage.Coverage()