Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ testing = [
"pytest-pretty>=1.1.0",
"pytest>=8.3.5",
"pytest-rerunfailures>=15.1",
"pytest-xdist",
"tensorstore>=0.1.32",
"virtualenv>=20.17",
"xarray>=0.16.2",
Expand Down Expand Up @@ -250,6 +251,7 @@ testing = [
"pytest-pretty>=1.1.0",
"pytest>=8.3.5",
"pytest-rerunfailures>=15.1",
"pytest-xdist",
"tensorstore>=0.1.32",
"virtualenv>=20.17",
"xarray>=0.16.2",
Expand Down
5 changes: 5 additions & 0 deletions src/napari/_qt/_tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def get_app_id():

def test_run_outside_ipython(make_napari_viewer, qapp, monkeypatch):
"""Test that we don't incorrectly give ipython the event loop."""
# Mock the IPython module to avoid side effects from other tests
# when running with pytest-xdist
import sys
monkeypatch.setitem(sys.modules, 'IPython', None)

assert not _ipython_has_eventloop()
v1 = make_napari_viewer()
assert not _ipython_has_eventloop()
Expand Down
2 changes: 1 addition & 1 deletion src/napari/_tests/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _get_provider_actions(type_):
superclass
).values()
)
return actions
return sorted(actions, key=lambda action: action.__name__)


def _assert_shortcuts_exist_for_each_action(type_):
Expand Down
10 changes: 9 additions & 1 deletion src/napari/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,15 @@ def _auto_shutdown_dask_threadworkers():
We don't assert the number of threads in unchanged as other things
modify the number of threads.
"""
assert dask.threaded.default_pool is None
# Reset pool regardless of initial state (handles xdist case)
if dask.threaded.default_pool is not None:
if isinstance(dask.threaded.default_pool, ThreadPool):
dask.threaded.default_pool.close()
dask.threaded.default_pool.join()
else:
dask.threaded.default_pool.shutdown()
dask.threaded.default_pool = None

try:
yield
finally:
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ indexserver =
commands =
cov: coverage run --parallel-mode \
!cov: python \
-m pytest {env:PYTEST_PATH:} --color=yes --basetemp={envtmpdir} \
-m pytest -n logical --dist loadfile --reruns 3 --reruns-delay 3 \
{env:PYTEST_PATH:} --color=yes --basetemp={envtmpdir} \
--ignore tools --maxfail=5 --json-report \
linux: --pystack-threshold=60 --pystack-args="--native-all" \
--json-report-file={toxinidir}/report-{envname}.json {posargs} \
--save-leaked-object-graph --import-mode=importlib

Expand Down
Loading