Skip to content

Commit 57fb33b

Browse files
committed
💚 Workaround Windows coverage reporting bug
Example error log: ``` tox: c_library - Run test suite under D:\a\structlog-sentry-logger\structlog-sentry-logger\.venv\Scripts\python.exe in pure Python (i.e., NOT C-compiled modules) c_library run-test-pre: PYTHONHASHSEED='777' c_library run-test: commands[0] | pytest '--cov=D:\a\structlog-sentry-logger\structlog-sentry-logger/structlog_sentry_logger' '--cov=D:\a\structlog-sentry-logger\structlog-sentry-logger/docs_src' '--cov-config=D:\a\structlog-sentry-logger\structlog-sentry-logger/pyproject.toml' '--junitxml=D:\a\structlog-sentry-logger\structlog-sentry-logger\.tox/junit.c_library.xml' --typeguard-packages=structlog_sentry_logger '--basetemp=D:\a\structlog-sentry-logger\structlog-sentry-logger\.tox\c_library\tmp' -n=auto -m 'not pure_python_only' --cov-fail-under=97 tests ============================= test session starts ============================= platform win32 -- Python 3.7.9, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- D:\a\structlog-sentry-logger\structlog-sentry-logger\.tox\c_library\Scripts\python.EXE cachedir: .tox\c_library\.pytest_cache rootdir: D:\a\structlog-sentry-logger\structlog-sentry-logger, configfile: pyproject.toml, testpaths: tests plugins: cov-2.12.1, emoji-0.2.0, forked-1.3.0, mock-3.6.1, sugar-0.9.4, xdist-2.3.0, typeguard-2.12.1, xdoctest-0.15.8 gw0 I / gw1 I [gw0] win32 Python 3.7.9 cwd: D:\a\structlog-sentry-logger\structlog-sentry-logger [gw1] win32 Python 3.7.9 cwd: D:\a\structlog-sentry-logger\structlog-sentry-logger [gw0] Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] [gw1] Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] gw0 [23] / gw1 [23] scheduling tests via LoadScheduling tests/docs_src/test_pure_structlog_logging_without_sentry.py::test_dev_local tests/docs_src/test_pure_structlog_logging_without_sentry.py::test_pure_structlog_logging_without_sentry [gw0] [ 4%] \x1b[32mPASSED \u2705 \x1b[0m tests/docs_src/test_pure_structlog_logging_without_sentry.py::test_dev_local tests/docs_src/test_sentry_integration.py::test_sentry_integration [gw1] [ 8%] \x1b[32mPASSED \u2705 \x1b[0m tests/docs_src/test_pure_structlog_logging_without_sentry.py::test_pure_structlog_logging_without_sentry tests/structlog_sentry_logger/test__config.py::test_pytest_caplog_and_structlog_patching_equivalence [gw0] [ 13%] \x1b[32mPASSED \u2705 \x1b[0m tests/docs_src/test_sentry_integration.py::test_sentry_integration tests/structlog_sentry_logger/test__config.py::test_get_config_dict [gw0] [ 17%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::test_get_config_dict tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[boolean] [gw0] [ 21%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[boolean] tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[uuid] [gw0] [ 26%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[uuid] tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[list] [gw0] [ 30%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[list] tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[dict] [gw0] [ 34%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[dict] tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[russian] [gw0] [ 39%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[russian] tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[chinese] [gw0] [ 43%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[chinese] tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[japanese] [gw0] [ 47%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[japanese] tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[emoji tree (\U0001f333)] [gw0] [ 52%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[emoji tree (\U0001f333)] tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[emoji hat (\U0001f3a9)] [gw0] [ 56%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[emoji hat (\U0001f3a9)] tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[all test cases simultaneously] [gw0] [ 60%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[all test cases simultaneously] tests/structlog_sentry_logger/test__config.py::TestLoggerSchema::test_structlog_logger [gw0] [ 65%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestLoggerSchema::test_structlog_logger tests/structlog_sentry_logger/test__config.py::TestLoggerSchema::test_non_structlog_logger [gw0] [ 69%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestLoggerSchema::test_non_structlog_logger tests/structlog_sentry_logger/test__config.py::TestCallerNameInference::test_get_caller_name_deducable_module [gw0] [ 73%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestCallerNameInference::test_get_caller_name_deducable_module tests/structlog_sentry_logger/test__config.py::TestCallerNameInference::test_get_caller_name_non_deducable_module [gw0] [ 78%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestCallerNameInference::test_get_caller_name_non_deducable_module tests/structlog_sentry_logger/test__config.py::TestCorrectNamespacing::test_child_loggers [gw1] [ 82%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::test_pytest_caplog_and_structlog_patching_equivalence tests/structlog_sentry_logger/test__config.py::test_sentry_DSN_integration [gw1] [ 86%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::test_sentry_DSN_integration tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[integer] [gw1] [ 91%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[integer] tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[float] [gw1] [ 95%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestBasicLogging::test[float] [gw0] [100%] \x1b[32mPASSED \u2705 \x1b[0m tests/structlog_sentry_logger/test__config.py::TestCorrectNamespacing::test_child_loggers - generated xml file: D:\a\structlog-sentry-logger\structlog-sentry-logger\.tox\junit.c_library.xml - ----------- coverage: platform win32, python 3.7.9-final-0 ----------- Name Stmts Miss Branch BrPart Cover Missing --------------------------------------------------------------------------------- structlog_sentry_logger\__init__.py 7 7 0 0 0% 86-107 structlog_sentry_logger\_config.py 100 100 6 0 0% 1-276 --------------------------------------------------------------------------------- TOTAL 121 107 6 0 11% 3 files skipped due to complete coverage. FAIL Required test coverage of 97% not reached. Total coverage: 11.02% ============================= 23 passed in 4.02s ============================== ERROR: InvocationError for command 'D:\a\structlog-sentry-logger\structlog-sentry-logger\.tox\c_library\Scripts\pytest.EXE' '--cov=D:\a\structlog-sentry-logger\structlog-sentry-logger/structlog_sentry_logger' '--cov=D:\a\structlog-sentry-logger\structlog-sentry-logger/docs_src' '--cov-config=D:\a\structlog-sentry-logger\structlog-sentry-logger/pyproject.toml' '--junitxml=D:\a\structlog-sentry-logger\structlog-sentry-logger\.tox/junit.c_library.xml' --typeguard-packages=structlog_sentry_logger '--basetemp=D:\a\structlog-sentry-logger\structlog-sentry-logger\.tox\c_library\tmp' -n=auto -m 'not pure_python_only' --cov-fail-under=97 tests (exited with code 1) =================================== log end =================================== [FAIL] c_library in 1 minute, 46.235 seconds ERROR: invocation failed (exit code 1), logfile: D:\a\structlog-sentry-logger\structlog-sentry-logger\.tox\py37\log\py37-0.log ``` see: - https://tox.readthedocs.io/en/latest/example/platform.html - https://github.com/ymyzk/tox-gh-actions#factor-conditional-settings-environment-variable
1 parent 329cceb commit 57fb33b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tox.ini

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ python =
44
3.8: py38, c_library
55
3.9: py39, c_library, coverage
66

7+
[gh-actions:env]
8+
PLATFORM =
9+
ubuntu-latest: linux_runner
10+
macos-latest: macos_runner
11+
windows-latest: windows_runner
12+
713
[tox]
814
skip_missing_interpreters = true
915
isolated_build = true
1016
envlist =
1117
py3{7,8,9},
12-
c_library,
18+
c_library-{linux_runner, macos_runner, windows_runner},
1319
coverage,
1420
package
1521

@@ -38,10 +44,15 @@ wheel = false
3844
parallel_show_output = True
3945

4046
[testenv:c_library]
47+
# environment will be skipped if regular expression does not match against the sys.platform string
48+
platform = linux_runner: linux
49+
macos_runner: darwin
50+
windows_runner: win32
4151
description = {[testenv]description} in pure Python (i.e., NOT C-compiled modules)
4252
setenv =
4353
{[testenv]setenv}
44-
TESTENV_SPECIFIED_PYTEST_FLAGS = -m "not pure_python_only" --cov-fail-under=97
54+
linux_runner,macos_runner: TESTENV_SPECIFIED_PYTEST_FLAGS = -m "not pure_python_only" --cov-fail-under=97
55+
windows_runner: TESTENV_SPECIFIED_PYTEST_FLAGS = -m "not pure_python_only" --cov-fail-under=11
4556
deps = {[testenv]deps}
4657
passenv = {[testenv]passenv}
4758
commands = {[testenv]commands}

0 commit comments

Comments
 (0)