From b09d170ada4defc920f3630946bf76786af10f45 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Fri, 5 Nov 2021 22:09:33 +0100 Subject: [PATCH] Add a config for pytest (#680) --- pytest.ini | 87 ++++++++++++++++++++++++++++++++++++++++ requirements-testing.txt | 1 + tox.ini | 2 +- 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..650a3693 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,87 @@ +[pytest] +addopts = + # FIXME: Enable this once the test suite has no race conditions + # `pytest-xdist`: + # --numprocesses=auto + + # Show 10 slowest invocations: + --durations=10 + + # A bit of verbosity doesn't hurt: + -v + + # Report all the things == -rxXs: + -ra + + # Show values of the local vars in errors/tracebacks: + --showlocals + + # Autocollect and invoke the doctests from all modules: + # https://docs.pytest.org/en/stable/doctest.html + --doctest-modules + + # Dump the test results in junit format: + --junitxml=.tox/tmp/test-results/pytest/results.xml + + # Fail on config parsing warnings: + --strict-config + + # Fail on non-existing markers: + # * Deprecated since v6.2.0 but may be reintroduced later covering a + # broader scope: + # --strict + # * Exists since v4.5.0 (advised to be used instead of `--strict`): + --strict-markers + + # `pytest-cov`: + # `pytest-cov`, "-p" preloads the module early: + -p pytest_cov + --no-cov-on-fail + --cov=proxy + --cov=tests/ + --cov-branch + --cov-report=term-missing:skip-covered + --cov-report=html:.tox/tmp/test-results/pytest/cov/ + --cov-report=xml + --cov-context=test + --cov-config=.coveragerc + +doctest_optionflags = ALLOW_UNICODE ELLIPSIS + +# Marks tests with an empty parameterset as xfail(run=False) +empty_parameter_set_mark = xfail + +faulthandler_timeout = 30 + +filterwarnings = + error + +junit_duration_report = call +# xunit1 contains more metadata than xunit2 so it's better for CI UIs: +junit_family = xunit1 +junit_logging = all +junit_log_passing_tests = true +junit_suite_name = proxy_py_test_suite + +# A mapping of markers to their descriptions allowed in strict mode: +markers = + +minversion = 6.2.0 + +# Optimize pytest's lookup by restricting potentially deep dir tree scan: +norecursedirs = + build + dist + docs + examples + proxy.egg-info + .cache + .eggs + .git + .github + .tox + *.egg + +testpaths = tests/ + +xfail_strict = true diff --git a/requirements-testing.txt b/requirements-testing.txt index 064bfe43..6beae2c4 100644 --- a/requirements-testing.txt +++ b/requirements-testing.txt @@ -4,6 +4,7 @@ coverage==6.1.1 flake8==4.0.1 pytest==6.2.5 pytest-cov==3.0.0 +pytest-xdist == 2.4.0 autopep8==1.6.0 mypy==0.910 py-spy==0.3.10 diff --git a/tox.ini b/tox.ini index 320e40c2..2bbdc5a1 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,7 @@ deps = # NOTE: `{envpython} -m pytest` because it'd add CWD into $PYTHONPATH # NOTE: testing the project from the Git checkout # NOTE: rather than one installed. -commands = pytest --cov=proxy --cov=tests/ --cov-report=xml tests/ {posargs:} +commands = pytest {posargs:} [dists]