summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-10-14 11:14:27 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-10-14 11:14:27 -0400
commita1101953f253754514e74d3d648c4d4ef9c0ad6c (patch)
tree0a268f5ea04cef8a44414c374cff81ae2db0c1ff
parent2e39e43d79b5ba38e5d3e693e847d6334462b55d (diff)
downloadpython-coveragepy-git-a1101953f253754514e74d3d648c4d4ef9c0ad6c.tar.gz
test: parametrize test_pathologically_long_code_object
While experimenting with packing branch ends into one int, this test showed a mistake I had made. Turns out it wasn't an obsolete test after all.
-rw-r--r--tests/test_arcs.py39
1 files changed, 18 insertions, 21 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 1284badc..f4a11839 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -1613,28 +1613,25 @@ class MiscArcTest(CoverageTest):
arcz=".1 15 5A A."
)
- def test_pathologically_long_code_object(self):
+ @pytest.mark.parametrize("n", [10, 50, 100, 500, 1000, 2000, 10000])
+ def test_pathologically_long_code_object(self, n):
# https://github.com/nedbat/coveragepy/issues/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
- # opcodes.
- # Note that we no longer interpret bytecode at all, but it couldn't
- # hurt to keep the test...
- sizes = [10, 50, 100, 500, 1000, 2000]
- for n in sizes:
- code = """\
- data = [
- """ + "".join("""\
- [
- {i}, {i}, {i}, {i}, {i}, {i}, {i}, {i}, {i}, {i}],
- """.format(i=i) for i in range(n)
- ) + """\
- ]
-
- print(len(data))
- """
- self.check_coverage(code, arcs=[(-1, 1), (1, 2*n+4), (2*n+4, -1)])
- assert self.stdout().split() == [str(n) for n in sizes]
+ # Long code objects sometimes cause problems. Originally, it was
+ # due to EXTENDED_ARG bytes codes. Then it showed a mistake in
+ # line-number packing.
+ code = """\
+ data = [
+ """ + "".join("""\
+ [
+ {i}, {i}, {i}, {i}, {i}, {i}, {i}, {i}, {i}, {i}],
+ """.format(i=i) for i in range(n)
+ ) + """\
+ ]
+
+ print(len(data))
+ """
+ self.check_coverage(code, arcs=[(-1, 1), (1, 2*n+4), (2*n+4, -1)])
+ assert self.stdout() == f"{n}\n"
def test_partial_generators(self):
# https://github.com/nedbat/coveragepy/issues/475