|
119 | 119 | #
|
120 | 120 |
|
121 | 121 | # stdlib
|
| 122 | +import os |
122 | 123 | import platform
|
123 | 124 | import sys
|
124 | 125 |
|
|
160 | 161 | # This ensures coverage.py records the correct coverage for these modules
|
161 | 162 | # when they are under test
|
162 | 163 |
|
163 |
| -for module in [m for m in sys.modules if m.startswith("domdf_python_tools")]: |
| 164 | +for module in [m for m in sys.modules if m.startswith("domdf_python_tools")]: # pragma: no cover (macOS) |
164 | 165 | if module in sys.modules:
|
165 | 166 | del sys.modules[module]
|
166 | 167 |
|
| 168 | +PYTHON_VERSION = os.environ.get("COV_PYTHON_VERSION", '.'.join(platform.python_version_tuple()[:2])) |
| 169 | +PLATFORM = os.environ.get("COV_PLATFORM", platform.system()).casefold() |
| 170 | +PYTHON_IMPLEMENTATION = os.environ.get("COV_PYTHON_IMPLEMENTATION", platform.python_implementation()).casefold() |
| 171 | + |
167 | 172 |
|
168 | 173 | @prettify_docstrings
|
169 | 174 | class VersionTag(packaging.specifiers.SpecifierSet):
|
@@ -208,8 +213,7 @@ def __repr__(self) -> str: # pragma: no cover
|
208 | 213 | return f"<{self.__class__.__name__}({str(self)!r})>"
|
209 | 214 |
|
210 | 215 | def __bool__(self) -> bool:
|
211 |
| - current_version = '.'.join(platform.python_version_tuple()[:2]) |
212 |
| - return current_version in self |
| 216 | + return PYTHON_VERSION in self |
213 | 217 |
|
214 | 218 |
|
215 | 219 | @prettify_docstrings
|
@@ -243,12 +247,10 @@ def __repr__(self) -> str: # pragma: no cover
|
243 | 247 | return f"<{self.__class__.__name__}({str(self)!r})>"
|
244 | 248 |
|
245 | 249 | def __bool__(self) -> bool:
|
246 |
| - current_platform = platform.system().casefold() |
247 |
| - |
248 |
| - if not current_platform: # pragma: no cover |
| 250 | + if not PLATFORM: # pragma: no cover |
249 | 251 | return True
|
250 | 252 |
|
251 |
| - return current_platform == self.casefold() |
| 253 | + return PLATFORM == self.casefold() |
252 | 254 |
|
253 | 255 |
|
254 | 256 | @prettify_docstrings
|
@@ -280,7 +282,7 @@ def __repr__(self) -> str: # pragma: no cover
|
280 | 282 | return f"<{self.__class__.__name__}({str(self)!r})>"
|
281 | 283 |
|
282 | 284 | def __bool__(self) -> bool:
|
283 |
| - return platform.python_implementation().casefold() == self.casefold() |
| 285 | + return PYTHON_IMPLEMENTATION == self.casefold() |
284 | 286 |
|
285 | 287 |
|
286 | 288 | @prettify_docstrings
|
|
0 commit comments