From bbc12f1b0261c9db9c3118070bf5530fb0a45495 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Tue, 20 Jan 2026 11:50:29 -0500 Subject: [PATCH] feat: migrate pytest configuration to pyproject.toml Migrates pytest configuration from setup.cfg, preserving all settings and comments including warning filters and test discovery patterns. Co-Authored-By: Claude Opus 4.5 --- pyproject.toml | 25 +++++++++++++++++++++++++ setup.cfg | 26 -------------------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c336a42f3b..5aab6cf8f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -179,3 +179,28 @@ team = "openedx.core.lib.teams_config:create_team_set_partition" [project.entry-points.console_scripts] xmodule_assets = "xmodule.static_content:main" + +[tool.pytest.ini_options] +# 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; +# but hide rate-limit warnings (because we deliberately don't throttle test user logins) +# and field_data deprecation warnings (because fixing them requires a major low-priority refactoring) +filterwarnings = [ + "default", + "ignore:No request passed to the backend, unable to rate-limit:UserWarning", + "ignore::xblock.exceptions.FieldDataDeprecationWarning", + # Remove default_app_config warning after updating Django to 4.2 + "ignore:.*You can remove default_app_config.*:PendingDeprecationWarning", + "ignore:Instead access HTTPResponse.headers directly.*:DeprecationWarning:elasticsearch", + # ABC deprecation Warning comes from libsass + "ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated.*:DeprecationWarning:sass", + "ignore:'etree' is deprecated. Use 'xml.etree.ElementTree' instead.:DeprecationWarning:wiki", +] +junit_family = "xunit2" +norecursedirs = ". .* *.egg build conf dist node_modules test_root cms/envs lms/envs openedx/envs" +python_classes = [] +python_files = ["tests.py", "test_*.py", "tests_*.py", "*_tests.py", "__init__.py"] diff --git a/setup.cfg b/setup.cfg index 28ea010b5e..78236a2881 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,29 +1,3 @@ -[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; -# but hide rate-limit warnings (because we deliberately don't throttle test user logins) -# and field_data deprecation warnings (because fixing them requires a major low-priority refactoring) -filterwarnings = - default - ignore:No request passed to the backend, unable to rate-limit:UserWarning - ignore::xblock.exceptions.FieldDataDeprecationWarning - # Remove default_app_config warning after updating Django to 4.2 - ignore:.*You can remove default_app_config.*:PendingDeprecationWarning - ignore:Instead access HTTPResponse.headers directly.*:DeprecationWarning:elasticsearch - # ABC deprecation Warning comes from libsass - ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated.*:DeprecationWarning:sass - ignore:'etree' is deprecated. Use 'xml.etree.ElementTree' instead.:DeprecationWarning:wiki - -junit_family = xunit2 -norecursedirs = .* *.egg build conf dist node_modules test_root cms/envs lms/envs openedx/envs -python_classes = -python_files = tests.py test_*.py tests_*.py *_tests.py __init__.py - [pycodestyle] # error codes: https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes # E501: line too long