-
Notifications
You must be signed in to change notification settings - Fork 228
Expand file tree
/
Copy pathconftest.py
More file actions
42 lines (31 loc) · 1.04 KB
/
conftest.py
File metadata and controls
42 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""conftest for zeroconf tests."""
from __future__ import annotations
import threading
from unittest.mock import patch
import pytest
from zeroconf import _core, const
from zeroconf._handlers import query_handler
@pytest.fixture(autouse=True)
def verify_threads_ended():
"""Verify that the threads are not running after the test."""
threads_before = frozenset(threading.enumerate())
yield
threads = frozenset(threading.enumerate()) - threads_before
assert not threads
@pytest.fixture
def run_isolated():
"""Change the mDNS port to run the test in isolation."""
with (
patch.object(query_handler, "_MDNS_PORT", 5454),
patch.object(_core, "_MDNS_PORT", 5454),
patch.object(const, "_MDNS_PORT", 5454),
):
yield
@pytest.fixture
def disable_duplicate_packet_suppression():
"""Disable duplicate packet suppress.
Some tests run too slowly because of the duplicate
packet suppression.
"""
with patch.object(const, "_DUPLICATE_PACKET_SUPPRESSION_INTERVAL", 0):
yield