From 66eae81add17a92dc7ea6fea5b3db9db0a0a0b9d Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 21 Dec 2021 07:47:59 -0800 Subject: [PATCH] docs: comments about how pytest finds settings (#29623) It took a while for me to understand why my setup.cfg setting was only applying to some tests. Hopefully these comments will save someone else some confusion. --- cms/pytest.ini | 4 ++++ common/lib/pytest.ini | 4 ++++ common/test/pytest.ini | 4 ++++ setup.cfg | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/cms/pytest.ini b/cms/pytest.ini index 14f323546b..add5ba084f 100644 --- a/cms/pytest.ini +++ b/cms/pytest.ini @@ -1,4 +1,8 @@ [pytest] +# Note: The first file of settings found is used, there is no combining, so +# this file is used for the tests in the cms tree, and setup.cfg is ignored. +# Details at https://docs.pytest.org/en/latest/reference/customize.html + DJANGO_SETTINGS_MODULE = cms.envs.test addopts = --nomigrations --reuse-db --durations=20 -p no:randomly --json-report --json-report-omit keywords streams collectors log traceback tests --json-report-file=none # Enable default handling for all warnings, including those that are ignored by default; diff --git a/common/lib/pytest.ini b/common/lib/pytest.ini index d169959544..aed75b7b1c 100644 --- a/common/lib/pytest.ini +++ b/common/lib/pytest.ini @@ -1,4 +1,8 @@ [pytest] +# Note: The first file of settings found is used, there is no combining, so +# this file is used for the tests in the common/lib tree, and setup.cfg is ignored. +# Details at https://docs.pytest.org/en/latest/reference/customize.html + # Use the LMS settings for these tests; should work with CMS just as well though: DJANGO_SETTINGS_MODULE = lms.envs.test addopts = --nomigrations --reuse-db --durations=20 --json-report --json-report-omit keywords streams collectors log traceback tests --json-report-file=none diff --git a/common/test/pytest.ini b/common/test/pytest.ini index 9ae1d23a98..03991b3495 100644 --- a/common/test/pytest.ini +++ b/common/test/pytest.ini @@ -1,4 +1,8 @@ [pytest] +# Note: The first file of settings found is used, there is no combining, so +# this file is used for the tests in the common/test tree, and setup.cfg is ignored. +# Details at https://docs.pytest.org/en/latest/reference/customize.html + addopts = -p no:randomly --durations=20 --json-report --json-report-omit keywords streams collectors log traceback tests --json-report-file=none # Enable default handling for all warnings, including those that are ignored by default; # but hide rate-limit warnings (because we deliberately don't throttle test user logins) diff --git a/setup.cfg b/setup.cfg index bf7d54a3c1..b923ea1357 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,8 @@ [tool:pytest] +# Note: The first file of settings found is used, there is no combining, so +# this file is only used for tests that don't find a pytest.ini file first. +# Details at https://docs.pytest.org/en/latest/reference/customize.html + DJANGO_SETTINGS_MODULE = lms.envs.test addopts = --nomigrations --reuse-db --durations=20 --json-report --json-report-omit keywords streams collectors log traceback tests --json-report-file=none # Enable default handling for all warnings, including those that are ignored by default;