diff options
Diffstat (limited to 'tests/test_arcs.py')
| -rw-r--r-- | tests/test_arcs.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py index d3717a8..81fa7e6 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -2,7 +2,9 @@ from tests.coveragetest import CoverageTest +import coverage from coverage import env +from coverage.files import abs_file class SimpleArcTest(CoverageTest): @@ -575,6 +577,27 @@ class MiscArcTest(CoverageTest): """, arcz=".1 19 9.") + def test_pathologically_long_code_object(self): + # https://bitbucket.org/ned/coveragepy/issue/359 + # The structure of this file is such that an EXTENDED_ARG byte code is + # needed to encode the jump at the end. We weren't interpreting those + # opcodes. + code = """\ + data = [ + """ + "".join("""\ + [{i}, {i}, {i}, {i}, {i}, {i}, {i}, {i}, {i}, {i}], + """.format(i=i) for i in range(2000) + ) + """\ + ] + + if __name__ == "__main__": + print(len(data)) + """ + self.check_coverage( + code, + arcs=[(-1, 1), (1, 2004), (2004, -2), (2004, 2005), (2005, -2)], + ) + class ExcludeTest(CoverageTest): """Tests of exclusions to indicate known partial branches.""" @@ -606,3 +629,24 @@ class ExcludeTest(CoverageTest): [1,2,3,4,5], partials=["only some"], arcz=".1 12 23 34 45 25 5.", arcz_missing="") + + +class LineDataTest(CoverageTest): + """Tests that line_data gives us what we expect.""" + + def test_branch(self): + cov = coverage.Coverage(branch=True) + + self.make_file("fun1.py", """\ + def fun1(x): + if x == 1: + return + + fun1(3) + """) + + self.start_import_stop(cov, "fun1") + + cov._harvest_data() + fun1_lines = cov.data.line_data()[abs_file("fun1.py")] + self.assertEqual(fun1_lines, [1, 2, 5]) |
