Skip to content

Commit 53051f1

Browse files
authored
Make tests order-independent (hynek#767)
1 parent 3cc86e6 commit 53051f1

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ Twitter = "https://twitter.com/hynek"
4141

4242
[dependency-groups]
4343
tests = [
44-
"time-machine>=2.14.1",
4544
"pytest-asyncio>=0.17",
45+
"pytest-randomly",
4646
"pytest>=6.0",
4747
"simplejson",
48+
"time-machine>=2.14.1",
4849
]
4950
# Need Twisted & Rich for stubs.
5051
# Otherwise mypy fails in tox.

tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ def _ensure_logging_framework_not_altered():
2929
Prevents 'ValueError: I/O operation on closed file.' errors.
3030
"""
3131
before_handlers = list(LOGGER.handlers)
32+
before_level = LOGGER.level
3233

3334
yield
3435

3536
LOGGER.handlers = before_handlers
37+
LOGGER.setLevel(before_level)
3638

3739

3840
@pytest.fixture(name="sio")

tests/test_dev.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ def test_negative(self):
3030
assert len("test") == len(dev._pad("test", 2))
3131

3232

33-
@pytest.fixture(name="cr", scope="session")
33+
@pytest.fixture(name="cr")
3434
def _cr():
3535
return dev.ConsoleRenderer(
3636
colors=dev._has_colors, exception_formatter=dev.plain_traceback
3737
)
3838

3939

40-
@pytest.fixture(name="styles", scope="session")
40+
@pytest.fixture(name="styles")
4141
def _styles(cr):
4242
return cr._styles
4343

4444

45-
@pytest.fixture(name="padded", scope="session")
45+
@pytest.fixture(name="padded")
4646
def _padded(styles):
4747
return styles.bright + dev._pad("test", dev._EVENT_WIDTH) + styles.reset
4848

0 commit comments

Comments
 (0)