Skip to content

Commit f275803

Browse files
committed
Ensure the imports from "domdf_python_tools" do not affect its coverage measurements.
1 parent 9fe0947 commit f275803

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

coverage_pyver_pragma/grammar.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120

121121
# stdlib
122122
import platform
123+
import sys
123124

124125
# 3rd party
125126
import packaging.specifiers
@@ -156,6 +157,17 @@
156157
"GRAMMAR",
157158
]
158159

160+
# This ensures coverage.py records the correct coverage for these modules
161+
# when they are under test
162+
163+
for module in [
164+
"domdf_python_tools",
165+
"domdf_python_tools.doctools",
166+
"domdf_python_tools.stringlist",
167+
]:
168+
if module in sys.modules:
169+
del sys.modules[module]
170+
159171

160172
@prettify_docstrings
161173
class VersionTag(packaging.specifiers.SpecifierSet):

0 commit comments

Comments
 (0)