summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-10-05 08:35:06 -0400
committerNed Batchelder <ned@nedbatchelder.com>2017-10-05 08:35:06 -0400
commit706d8959bcaba3a37c9e56a818ef0ebe5835bb70 (patch)
tree76bdbe3cd832ea249d50b0630720329e4fb93419
parentd06272c71a9e80f88b0b1f3fccf93772cb47e8f2 (diff)
downloadpython-coveragepy-706d8959bcaba3a37c9e56a818ef0ebe5835bb70.tar.gz
Add an explicit test for weird module docstring behavior.
-rw-r--r--CHANGES.rst4
-rw-r--r--tests/test_coverage.py23
2 files changed, 26 insertions, 1 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 9556bf0..bc44710 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -8,7 +8,9 @@ Change history for Coverage.py
Unreleased
----------
-(nothing yet)
+- Support for Python 3.7. In some cases, class and module docstrings are no
+ longer counted in statement totals, which could slightly change your total
+ results.
.. _changes_441:
diff --git a/tests/test_coverage.py b/tests/test_coverage.py
index fae85bc..45abb2b 100644
--- a/tests/test_coverage.py
+++ b/tests/test_coverage.py
@@ -574,6 +574,29 @@ class SimpleStatementTest(CoverageTest):
[2, 3]
)
+ def test_module_docstring(self):
+ self.check_coverage("""\
+ '''I am a module docstring.'''
+ a = 2
+ b = 3
+ """,
+ [2, 3]
+ )
+ if env.PYVERSION < (3, 7):
+ # Before 3.7, module docstrings were included in the lnotab table,
+ # unless they were the first line in the file?
+ lines = [2, 3, 4]
+ else:
+ lines = [3, 4]
+ self.check_coverage("""\
+ # Start with a comment, because it changes the behavior(!?)
+ '''I am a module docstring.'''
+ a = 3
+ b = 4
+ """,
+ lines
+ )
+
class CompoundStatementTest(CoverageTest):
"""Testing coverage of multi-line compound statements."""