diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2022-07-12 08:05:49 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2022-07-12 08:39:01 -0400 |
commit | 0d6449874cd4d3003ce908d66fa654b64bfea0c0 (patch) | |
tree | e6f2449abf080fa99562b7efe4952675d6fdd5ec /tests/test_lcov.py | |
parent | 297b70e43e083297093781be6e5e1681e5dd70cb (diff) | |
download | python-coveragepy-git-0d6449874cd4d3003ce908d66fa654b64bfea0c0.tar.gz |
fix: 3.11.0b4 has 0-numbered lines. Fixes #1419
CPython added these lines in
https://github.com/python/cpython/commit/1bfe83a114da3939c00746fc44dc5da7f56f525f
Diffstat (limited to 'tests/test_lcov.py')
-rw-r--r-- | tests/test_lcov.py | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/tests/test_lcov.py b/tests/test_lcov.py index f31d8c17..09bb99aa 100644 --- a/tests/test_lcov.py +++ b/tests/test_lcov.py @@ -8,6 +8,7 @@ import textwrap from tests.coveragetest import CoverageTest import coverage +from coverage import env class LcovTest(CoverageTest): @@ -252,7 +253,8 @@ class LcovTest(CoverageTest): line. It will also note the lack of branches, and the checksum for the line. - Although there are no lines found, it will note one line as hit. + Although there are no lines found, it will note one line as hit in + old Pythons, and no lines hit in newer Pythons. """ self.make_file("__init__.py", "") @@ -261,15 +263,27 @@ class LcovTest(CoverageTest): self.start_import_stop(cov, "__init__") cov.lcov_report() self.assert_exists("coverage.lcov") - expected_result = textwrap.dedent("""\ - TN: - SF:__init__.py - DA:1,1,1B2M2Y8AsgTpgAmY7PhCfg - LF:0 - LH:1 - BRF:0 - BRH:0 - end_of_record - """) + # Newer Pythons have truly empty empty files. + if env.PYBEHAVIOR.empty_is_empty: + expected_result = textwrap.dedent("""\ + TN: + SF:__init__.py + LF:0 + LH:0 + BRF:0 + BRH:0 + end_of_record + """) + else: + expected_result = textwrap.dedent("""\ + TN: + SF:__init__.py + DA:1,1,1B2M2Y8AsgTpgAmY7PhCfg + LF:0 + LH:1 + BRF:0 + BRH:0 + end_of_record + """) actual_result = self.get_lcov_report_content() assert actual_result == expected_result |