summaryrefslogtreecommitdiff
path: root/tests/test_oddball.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_oddball.py')
-rw-r--r--tests/test_oddball.py41
1 files changed, 21 insertions, 20 deletions
diff --git a/tests/test_oddball.py b/tests/test_oddball.py
index ca139737..a44beae4 100644
--- a/tests/test_oddball.py
+++ b/tests/test_oddball.py
@@ -24,7 +24,7 @@ from tests import osinfo
class ThreadingTest(CoverageTest):
"""Tests of the threading support."""
- def test_threading(self):
+ def test_threading(self) -> None:
self.check_coverage("""\
import threading
@@ -44,7 +44,7 @@ class ThreadingTest(CoverageTest):
""",
[1, 3, 4, 6, 7, 9, 10, 12, 13, 14, 15], "10")
- def test_thread_run(self):
+ def test_thread_run(self) -> None:
self.check_coverage("""\
import threading
@@ -67,7 +67,7 @@ class ThreadingTest(CoverageTest):
class RecursionTest(CoverageTest):
"""Check what happens when recursive code gets near limits."""
- def test_short_recursion(self):
+ def test_short_recursion(self) -> None:
# We can definitely get close to 500 stack frames.
self.check_coverage("""\
def recur(n):
@@ -81,7 +81,7 @@ class RecursionTest(CoverageTest):
""",
[1, 2, 3, 5, 7, 8], "")
- def test_long_recursion(self):
+ def test_long_recursion(self) -> None:
# We can't finish a very deep recursion, but we don't crash.
with pytest.raises(RuntimeError):
with swallow_warnings("Trace function changed, data is likely wrong: None"):
@@ -97,7 +97,7 @@ class RecursionTest(CoverageTest):
[1, 2, 3, 5, 7], ""
)
- def test_long_recursion_recovery(self):
+ def test_long_recursion_recovery(self) -> None:
# Test the core of bug 93: https://github.com/nedbat/coveragepy/issues/93
# When recovering from a stack overflow, the Python trace function is
# disabled, but the C trace function is not. So if we're using a
@@ -157,7 +157,7 @@ class MemoryLeakTest(CoverageTest):
"""
@flaky
@pytest.mark.skipif(not env.C_TRACER, reason="Only the C tracer has refcounting issues")
- def test_for_leaks(self):
+ def test_for_leaks(self) -> None:
# Our original bad memory leak only happened on line numbers > 255, so
# make a code object with more lines than that. Ugly string mumbo
# jumbo to get 300 blank lines at the beginning..
@@ -204,7 +204,7 @@ class MemoryFumblingTest(CoverageTest):
"""Test that we properly manage the None refcount."""
@pytest.mark.skipif(not env.C_TRACER, reason="Only the C tracer has refcounting issues")
- def test_dropping_none(self): # pragma: not covered
+ def test_dropping_none(self) -> None: # pragma: not covered
# TODO: Mark this so it will only be run sometimes.
pytest.skip("This is too expensive for now (30s)")
# Start and stop coverage thousands of times to flush out bad
@@ -238,7 +238,7 @@ class MemoryFumblingTest(CoverageTest):
class PyexpatTest(CoverageTest):
"""Pyexpat screws up tracing. Make sure we've counter-defended properly."""
- def test_pyexpat(self):
+ def test_pyexpat(self) -> None:
# pyexpat calls the trace function explicitly (inexplicably), and does
# it wrong for exceptions. Parsing a DOCTYPE for some reason throws
# an exception internally, and triggers its wrong behavior. This test
@@ -290,7 +290,7 @@ class ExceptionTest(CoverageTest):
in the trace function.
"""
- def test_exception(self):
+ def test_exception(self) -> None:
# Python 2.3's trace function doesn't get called with "return" if the
# scope is exiting due to an exception. This confounds our trace
# function which relies on scope announcements to track which files to
@@ -368,8 +368,8 @@ class ExceptionTest(CoverageTest):
for callnames, lines_expected in runs:
# Make the list of functions we'll call for this test.
- callnames = callnames.split()
- calls = [getattr(sys.modules[cn], cn) for cn in callnames]
+ callnames_list = callnames.split()
+ calls = [getattr(sys.modules[cn], cn) for cn in callnames_list]
cov = coverage.Coverage()
cov.start()
@@ -382,7 +382,7 @@ class ExceptionTest(CoverageTest):
# The file names are absolute, so keep just the base.
clean_lines = {}
data = cov.get_data()
- for callname in callnames:
+ for callname in callnames_list:
filename = callname + ".py"
clean_lines[filename] = sorted_lines(data, abs_file(filename))
@@ -392,7 +392,7 @@ class ExceptionTest(CoverageTest):
class DoctestTest(CoverageTest):
"""Tests invoked with doctest should measure properly."""
- def test_doctest(self):
+ def test_doctest(self) -> None:
# Doctests used to be traced, with their line numbers credited to the
# file they were in. Below, one of the doctests has four lines (1-4),
# which would incorrectly claim that lines 1-4 of the file were
@@ -433,7 +433,7 @@ class DoctestTest(CoverageTest):
class GettraceTest(CoverageTest):
"""Tests that we work properly with `sys.gettrace()`."""
- def test_round_trip_in_untraced_function(self):
+ def test_round_trip_in_untraced_function(self) -> None:
# https://github.com/nedbat/coveragepy/issues/575
self.make_file("main.py", """import sample""")
self.make_file("sample.py", """\
@@ -466,7 +466,7 @@ class GettraceTest(CoverageTest):
assert statements == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
assert missing == []
- def test_setting_new_trace_function(self):
+ def test_setting_new_trace_function(self) -> None:
# https://github.com/nedbat/coveragepy/issues/436
self.check_coverage('''\
import os.path
@@ -484,7 +484,7 @@ class GettraceTest(CoverageTest):
t = sys.gettrace()
assert t is tracer, t
- def test_unsets_trace():
+ def test_unsets_trace() -> None:
begin()
collect()
@@ -498,6 +498,7 @@ class GettraceTest(CoverageTest):
missing="5-7, 13-14",
)
+ assert self.last_module_name is not None
out = self.stdout().replace(self.last_module_name, "coverage_test")
expected = (
"call: coverage_test.py @ 12\n" +
@@ -509,7 +510,7 @@ class GettraceTest(CoverageTest):
@pytest.mark.expensive
@pytest.mark.skipif(env.METACOV, reason="Can't set trace functions during meta-coverage")
- def test_atexit_gettrace(self):
+ def test_atexit_gettrace(self) -> None:
# This is not a test of coverage at all, but of our understanding
# of this edge-case behavior in various Pythons.
@@ -541,7 +542,7 @@ class GettraceTest(CoverageTest):
class ExecTest(CoverageTest):
"""Tests of exec."""
- def test_correct_filename(self):
+ def test_correct_filename(self) -> None:
# https://github.com/nedbat/coveragepy/issues/380
# Bug was that exec'd files would have their lines attributed to the
# calling file. Make two files, both with ~30 lines, but no lines in
@@ -570,7 +571,7 @@ class ExecTest(CoverageTest):
assert statements == [31]
assert missing == []
- def test_unencodable_filename(self):
+ def test_unencodable_filename(self) -> None:
# https://github.com/nedbat/coveragepy/issues/891
self.make_file("bug891.py", r"""exec(compile("pass", "\udcff.py", "exec"))""")
cov = coverage.Coverage()
@@ -587,7 +588,7 @@ class MockingProtectionTest(CoverageTest):
https://github.com/nedbat/coveragepy/issues/416
"""
- def test_os_path_exists(self):
+ def test_os_path_exists(self) -> None:
# To see if this test still detects the problem, change isolate_module
# in misc.py to simply return its argument. It should fail with a
# StopIteration error.