Skip to content

Commit 8c455a6

Browse files
authored
Revert "Add test setup fixture (#5242)" (#5300)
This reverts commit b0c9dc4.
1 parent 2df7d7e commit 8c455a6

File tree

2 files changed

+25
-39
lines changed

2 files changed

+25
-39
lines changed

conftest.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
# https://pytest.org/latest/example/simple.html#control-skipping-of-tests-according-to-command-line-option
2-
import copy
3-
import logging
4-
52
import pytest
63

7-
import dask
8-
94
# Uncomment to enable more logging and checks
105
# (https://docs.python.org/3/library/asyncio-dev.html)
116
# Note this makes things slower and might consume much memory.
@@ -40,31 +35,3 @@ def pytest_collection_modifyitems(config, items):
4035

4136

4237
pytest_plugins = ["distributed.pytest_resourceleaks"]
43-
44-
45-
_original_config = copy.deepcopy(dask.config.config)
46-
# Custom preloads can interact with the test suite in unexpected ways
47-
# so we remove them when running tests
48-
for node in ["scheduler", "worker", "nanny"]:
49-
_original_config["distributed"][node]["preload"] = []
50-
_original_config["distributed"][node]["preload-argv"] = []
51-
52-
_logging_levels = {
53-
name: logger.level
54-
for name, logger in logging.root.manager.loggerDict.items()
55-
if isinstance(logger, logging.Logger)
56-
}
57-
58-
59-
@pytest.fixture(autouse=True)
60-
def initialize_test():
61-
62-
# Restore default logging levels
63-
for name, level in _logging_levels.items():
64-
logging.getLogger(name).setLevel(level)
65-
66-
# Ensure a clean config
67-
dask.config.config.clear()
68-
dask.config.config.update(copy.deepcopy(_original_config))
69-
70-
yield

distributed/utils_test.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@
7777
logger = logging.getLogger(__name__)
7878

7979

80+
logging_levels = {
81+
name: logger.level
82+
for name, logger in logging.root.manager.loggerDict.items()
83+
if isinstance(logger, logging.Logger)
84+
}
85+
8086
_TEST_TIMEOUT = 30
8187
_offload_executor.submit(lambda: None).result() # create thread during import
8288

@@ -209,6 +215,14 @@ def get_ip():
209215
remote_magic._clients.clear()
210216

211217

218+
original_config = copy.deepcopy(dask.config.config)
219+
220+
221+
def reset_config():
222+
dask.config.config.clear()
223+
dask.config.config.update(copy.deepcopy(original_config))
224+
225+
212226
def nodebug(func):
213227
"""
214228
A decorator to disable debug facilities during timing-sensitive tests.
@@ -1571,13 +1585,18 @@ def clean(threads=not WINDOWS, instances=True, timeout=1, processes=True):
15711585
with check_process_leak(check=processes):
15721586
with check_instances() if instances else nullcontext():
15731587
with check_active_rpc(loop, timeout):
1574-
with dask.config.set(
1575-
{"distributed.comm.timeouts.connect": "5s"}
1576-
):
1577-
yield loop
1588+
reset_config()
1589+
1590+
dask.config.set({"distributed.comm.timeouts.connect": "5s"})
1591+
# Restore default logging levels
1592+
# XXX use pytest hooks/fixtures instead?
1593+
for name, level in logging_levels.items():
1594+
logging.getLogger(name).setLevel(level)
1595+
1596+
yield loop
15781597

1579-
with suppress(AttributeError):
1580-
del thread_state.on_event_loop_thread
1598+
with suppress(AttributeError):
1599+
del thread_state.on_event_loop_thread
15811600

15821601

15831602
@pytest.fixture

0 commit comments

Comments
 (0)