From f275803638c4816eb7eeb173e5d2a6169ae990d7 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Mon, 8 Mar 2021 23:02:56 +0000 Subject: [PATCH] Ensure the imports from "domdf_python_tools" do not affect its coverage measurements. --- coverage_pyver_pragma/grammar.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/coverage_pyver_pragma/grammar.py b/coverage_pyver_pragma/grammar.py index a2db3ef..91f2a73 100644 --- a/coverage_pyver_pragma/grammar.py +++ b/coverage_pyver_pragma/grammar.py @@ -120,6 +120,7 @@ # stdlib import platform +import sys # 3rd party import packaging.specifiers @@ -156,6 +157,17 @@ "GRAMMAR", ] +# This ensures coverage.py records the correct coverage for these modules +# when they are under test + +for module in [ + "domdf_python_tools", + "domdf_python_tools.doctools", + "domdf_python_tools.stringlist", + ]: + if module in sys.modules: + del sys.modules[module] + @prettify_docstrings class VersionTag(packaging.specifiers.SpecifierSet):