Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up test suite with pytest-xdist #2537

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Skip reload tests on windows and mac
Kludex committed Dec 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit aa994a82aae873bd1f46f3c3dc0b3901663c1047
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ disallow_untyped_defs = false
check_untyped_defs = true

[tool.pytest.ini_options]
addopts = "-rxXs --strict-config --strict-markers -n 8 --dist loadgroup"
addopts = "-rxXs --strict-config --strict-markers -n 8"
xfail_strict = true
filterwarnings = [
"error",
2 changes: 0 additions & 2 deletions tests/supervisors/test_multiprocess.py
Original file line number Diff line number Diff line change
@@ -15,8 +15,6 @@
from uvicorn.supervisors import Multiprocess
from uvicorn.supervisors.multiprocess import Process

pytestmark = pytest.mark.xdist_group(name="multiprocess")


def new_console_in_windows(test_function: Callable[[], Any]) -> Callable[[], Any]: # pragma: no cover
if os.name != "nt":
18 changes: 8 additions & 10 deletions tests/supervisors/test_reload.py
Original file line number Diff line number Diff line change
@@ -22,12 +22,10 @@
except ImportError: # pragma: no cover
WatchFilesReload = None # type: ignore[misc,assignment]

pytestmark = pytest.mark.xdist_group(name="reloader")

# TODO: Investigate why this is flaky on MacOS M1.
skip_if_m1 = pytest.mark.skipif(
sys.platform == "darwin" and platform.processor() == "arm",
reason="Flaky on MacOS M1",
# TODO: Investigate why this is flaky on MacOS M1, and Windows.
pytestmark = pytest.mark.skipif(
(sys.platform == "darwin" and platform.processor() == "arm") or sys.platform == "win32",
reason="Flaky on MacOS M1, and Windows",
)


@@ -153,7 +151,7 @@ def test_reload_when_pattern_matched_file_is_changed(self, result: bool, touch_s

reloader.shutdown()

@pytest.mark.parametrize("reloader_class", [pytest.param(WatchFilesReload, marks=skip_if_m1)])
@pytest.mark.parametrize("reloader_class", [WatchFilesReload])
def test_should_not_reload_when_exclude_pattern_match_file_is_changed(
self, touch_soon: Callable[[Path], None]
): # pragma: py-darwin
@@ -210,7 +208,7 @@ def test_should_reload_when_directories_have_same_prefix(self, touch_soon: Calla

@pytest.mark.parametrize(
"reloader_class",
[StatReload, pytest.param(WatchFilesReload, marks=skip_if_m1)],
[StatReload, pytest.param(WatchFilesReload)],
)
def test_should_not_reload_when_only_subdirectory_is_watched(self, touch_soon: Callable[[Path], None]):
app_dir = self.reload_path / "app"
@@ -229,7 +227,7 @@ def test_should_not_reload_when_only_subdirectory_is_watched(self, touch_soon: C

reloader.shutdown()

@pytest.mark.parametrize("reloader_class", [pytest.param(WatchFilesReload, marks=skip_if_m1)])
@pytest.mark.parametrize("reloader_class", [pytest.param(WatchFilesReload)])
def test_override_defaults(self, touch_soon: Callable[[Path], None]) -> None: # pragma: py-darwin
dotted_file = self.reload_path / ".dotted"
dotted_dir_file = self.reload_path / ".dotted_dir" / "file.txt"
@@ -251,7 +249,7 @@ def test_override_defaults(self, touch_soon: Callable[[Path], None]) -> None: #

reloader.shutdown()

@pytest.mark.parametrize("reloader_class", [pytest.param(WatchFilesReload, marks=skip_if_m1)])
@pytest.mark.parametrize("reloader_class", [pytest.param(WatchFilesReload)])
def test_explicit_paths(self, touch_soon: Callable[[Path], None]) -> None: # pragma: py-darwin
dotted_file = self.reload_path / ".dotted"
non_dotted_file = self.reload_path / "ext" / "ext.jpg"