mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-07 10:53:26 +03:00
tests: Improved coverage reporting
* Always report on coverage, if no tests failed. * Remove `.coveragerc`, in favour of `pyproject.toml`. * Use `coverage-conditional-plugin`: - Two rules added, `sys-platform-win32` and `sys-platform-not-win32`. - Those rules used so non-win32 code run on win32 doesn't cause coverage to be reported as less than 100%. There's the assumption that !win32 means Linux, probably.
This commit is contained in:
parent
bacd2ef9c6
commit
1b0bbb9a56
@ -1,6 +0,0 @@
|
|||||||
[run]
|
|
||||||
omit =
|
|
||||||
# The tests themselves
|
|
||||||
tests/*
|
|
||||||
# Any venv files
|
|
||||||
venv/*
|
|
@ -94,7 +94,7 @@ class JournalLock:
|
|||||||
|
|
||||||
:return: LockResult - See the class Enum definition
|
:return: LockResult - See the class Enum definition
|
||||||
"""
|
"""
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32': # pragma: sys-platform-not-win32
|
||||||
logger.trace_if('journal-lock', 'win32, using msvcrt')
|
logger.trace_if('journal-lock', 'win32, using msvcrt')
|
||||||
# win32 doesn't have fcntl, so we have to use msvcrt
|
# win32 doesn't have fcntl, so we have to use msvcrt
|
||||||
import msvcrt
|
import msvcrt
|
||||||
@ -107,7 +107,7 @@ class JournalLock:
|
|||||||
f", assuming another process running: {e!r}")
|
f", assuming another process running: {e!r}")
|
||||||
return JournalLockResult.ALREADY_LOCKED
|
return JournalLockResult.ALREADY_LOCKED
|
||||||
|
|
||||||
else: # pytest coverage only sees this on !win32
|
else: # pragma: sys-platform-win32
|
||||||
logger.trace_if('journal-lock', 'NOT win32, using fcntl')
|
logger.trace_if('journal-lock', 'NOT win32, using fcntl')
|
||||||
try:
|
try:
|
||||||
import fcntl
|
import fcntl
|
||||||
@ -143,7 +143,7 @@ class JournalLock:
|
|||||||
return True # We weren't locked, and still aren't
|
return True # We weren't locked, and still aren't
|
||||||
|
|
||||||
unlocked = False
|
unlocked = False
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32': # pragma: sys-platform-not-win32
|
||||||
logger.trace_if('journal-lock', 'win32, using msvcrt')
|
logger.trace_if('journal-lock', 'win32, using msvcrt')
|
||||||
# win32 doesn't have fcntl, so we have to use msvcrt
|
# win32 doesn't have fcntl, so we have to use msvcrt
|
||||||
import msvcrt
|
import msvcrt
|
||||||
@ -160,7 +160,7 @@ class JournalLock:
|
|||||||
else:
|
else:
|
||||||
unlocked = True
|
unlocked = True
|
||||||
|
|
||||||
else: # pytest coverage only sees this on !win32
|
else: # pragma: sys-platform-win32
|
||||||
logger.trace_if('journal-lock', 'NOT win32, using fcntl')
|
logger.trace_if('journal-lock', 'NOT win32, using fcntl')
|
||||||
try:
|
try:
|
||||||
import fcntl
|
import fcntl
|
||||||
|
@ -7,9 +7,16 @@ line_length = 119
|
|||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
testpaths = ["tests"] # Search for tests in tests/
|
testpaths = ["tests"] # Search for tests in tests/
|
||||||
|
addopts = "--cov . --cov plugins --cov-report=term-missing --no-cov-on-fail"
|
||||||
|
# --cov-fail-under 80"
|
||||||
|
|
||||||
[tool.coverage.run]
|
[tool.coverage.run]
|
||||||
omit = ["venv/*"] # when running pytest --cov, dont report coverage in venv directories
|
omit = [ "tests/*", "venv/*", "dist.win32/*" ]
|
||||||
|
plugins = [ "coverage_conditional_plugin" ]
|
||||||
|
|
||||||
|
[tool.coverage.coverage_conditional_plugin.rules]
|
||||||
|
sys-platform-win32 = "sys_platform == 'win32'"
|
||||||
|
sys-platform-not-win32 = "sys_platform != 'win32'"
|
||||||
|
|
||||||
[tool.pyright]
|
[tool.pyright]
|
||||||
# pythonPlatform = 'Darwin'
|
# pythonPlatform = 'Darwin'
|
||||||
|
@ -43,6 +43,7 @@ py2exe==0.12.0.1; sys_platform == 'win32'
|
|||||||
pytest==7.1.3
|
pytest==7.1.3
|
||||||
pytest-cov==4.0.0 # Pytest code coverage support
|
pytest-cov==4.0.0 # Pytest code coverage support
|
||||||
coverage[toml]==6.5.0 # pytest-cov dep. This is here to ensure that it includes TOML support for pyproject.toml configs
|
coverage[toml]==6.5.0 # pytest-cov dep. This is here to ensure that it includes TOML support for pyproject.toml configs
|
||||||
|
coverage-conditional-plugin==0.7.0
|
||||||
# For manipulating folder permissions and the like.
|
# For manipulating folder permissions and the like.
|
||||||
pywin32==304; sys_platform == 'win32'
|
pywin32==304; sys_platform == 'win32'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user