Skip to content

Commit eb3181a

Browse files
smackeseyDagster Devtools
authored andcommitted
Standardize pytest between oss/internal (#21661)
## Summary Standardizes pytest configuration between the internal and dagster-oss repositories: - Shared conftest: internal/conftest.py now delegates to dagster-oss/conftest.py via importlib instead of duplicating hooks (--split, pytest_configure, pytest_runtest_setup, pytest_collection_modifyitems). This keeps dagster-oss standalone while eliminating drift. - Aligned pyproject.toml: Both pyproject.toml files now declare the same pytest settings (addopts, filterwarnings, markers, asyncio_mode, asyncio_default_fixture_loop_scope, timeout) with consistent comments. - Removed dead config: Dropped the redundant integration marker registration from dagster-oss/conftest.py (already in pyproject.toml), removed unused unit and e2e markers, and removed the no-op --ignore=dbt/dbt_packages from internal. - Added comments: Explanatory comments for all pytest config options in both pyproject.toml files. ## Test plan Existing test suite. Internal-RevId: ccdcf06ab2fc3d00e3d38b89225643712c01b969
1 parent f69308a commit eb3181a

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

conftest.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
import pytest
55

6+
# We have to define these warnings filters here instead of in
7+
# static config because the dagster package is not guaranteed to be installed
8+
# in all test suites that use this conftest.py.
69
try:
710
from dagster import BetaWarning, PreviewWarning, SupersessionWarning
811

@@ -26,11 +29,6 @@ def pytest_configure(config):
2629
if os.getenv("BUILDKITE"):
2730
print("+++ Running :pytest: PyTest") # noqa
2831

29-
# https://docs.pytest.org/en/7.1.x/example/markers.html#custom-marker-and-command-line-option-to-control-test-runs
30-
config.addinivalue_line(
31-
"markers", "integration: mark test to skip if DISABLE_INTEGRATION_TESTS is set."
32-
)
33-
3432

3533
def pytest_runtest_setup(item):
3634
try:

pyproject.toml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,49 @@ executionEnvironments = [
8181

8282
[tool.pytest.ini_options]
8383

84+
# Append these options to all pytest invocations.
85+
addopts = [
86+
# Treat unregistered markers as errors to avoid silent typos and ensure all markers are declared in the config.
87+
"--strict-markers",
88+
89+
# Show short summary of all non-passing tests (failed, errored, skipped,
90+
# etc.) at the end of output.
91+
"-ra"
92+
]
93+
94+
# Don't print any of these warnings during test runs.
8495
filterwarnings = [
8596
"ignore::DeprecationWarning",
8697
"ignore::UserWarning",
8798
"ignore::pytest.PytestCollectionWarning",
8899
]
89100

101+
# Custom markers for categorizing tests. These should be used in test code as
102+
# `@pytest.mark.<marker_name>`. They can be used to select or deselect tests
103+
# when running pytest, e.g. `pytest -m "not slow"` to run all tests except
104+
# those marked as slow.
90105
markers = [
91-
"unit: Fast unit tests with no external dependencies",
92106
"integration: Tests requiring real git operations or other I/O",
93-
"e2e: End-to-end tests requiring GitHub authentication",
94107
"slow: Tests that take more than 1 second",
95108
]
96109

97-
timeout = 240
98-
addopts = "-ra"
110+
### pytest-asyncio configuration
111+
112+
# Auto mode: async def test_* functions are automatically treated as async tests without
113+
# needing @pytest.mark.asyncio on each one. Same for async fixtures.
114+
asyncio_mode = "auto"
115+
116+
# Use a single event loop for the entire test session, shared across all async fixtures
117+
# (unless a fixture explicitly declares a different scope).
118+
asyncio_default_fixture_loop_scope = "session"
119+
120+
### pytest-timeout configuration
121+
122+
# Timeout for individual tests, in seconds. This value is intentionally large
123+
# as it should not be the default way we catch tests that timeout. The tests
124+
# themselves should be written such that they fail if something is taking too
125+
# long. This is just a fallback to ensure our test suite does not hang forever.
126+
timeout = "240"
99127

100128
# ########################
101129
# ##### RUFF

0 commit comments

Comments
 (0)