forked from python-zeroconf/python-zeroconf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
30 lines (20 loc) · 669 Bytes
/
conftest.py
File metadata and controls
30 lines (20 loc) · 669 Bytes
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
#!/usr/bin/env python
""" conftest for zeroconf tests. """
import threading
import pytest
import unittest
from zeroconf import _core, const
@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 unittest.mock.patch.object(_core, "_MDNS_PORT", 5454), unittest.mock.patch.object(
const, "_MDNS_PORT", 5454
):
yield