|
37 | 37 | original_logging_level = logging.NOTSET |
38 | 38 |
|
39 | 39 |
|
| 40 | +@pytest.fixture(autouse=True) |
| 41 | +def verify_threads_ended(): |
| 42 | + """Verify that the threads are not running after the test.""" |
| 43 | + threads_before = frozenset(threading.enumerate()) |
| 44 | + yield |
| 45 | + threads = frozenset(threading.enumerate()) - threads_before |
| 46 | + assert not threads |
| 47 | + |
| 48 | + |
40 | 49 | def setup_module(): |
41 | 50 | global original_logging_level |
42 | 51 | original_logging_level = log.level |
@@ -924,6 +933,7 @@ def send(out, addr=r._MDNS_ADDR, port=r._MDNS_PORT): |
924 | 933 | zc.unregister_service(info) |
925 | 934 | assert nbr_answers == 12 and nbr_additionals == 0 and nbr_authorities == 0 |
926 | 935 | nbr_answers = nbr_additionals = nbr_authorities = 0 |
| 936 | + zc.close() |
927 | 937 |
|
928 | 938 | def test_name_conflicts(self): |
929 | 939 | # instantiate a zeroconf instance |
@@ -952,6 +962,7 @@ def test_name_conflicts(self): |
952 | 962 | ) |
953 | 963 | with pytest.raises(r.NonUniqueNameException): |
954 | 964 | zc.register_service(conflicting_info) |
| 965 | + zc.close() |
955 | 966 |
|
956 | 967 |
|
957 | 968 | class TestServiceRegistry(unittest.TestCase): |
@@ -1598,6 +1609,7 @@ def test_service_info_rejects_non_matching_updates(self): |
1598 | 1609 | ), |
1599 | 1610 | ) |
1600 | 1611 | assert new_address not in info.addresses |
| 1612 | + zc.close() |
1601 | 1613 |
|
1602 | 1614 | def test_get_info_partial(self): |
1603 | 1615 |
|
@@ -2188,6 +2200,7 @@ def send(out, addr=r._MDNS_ADDR, port=r._MDNS_PORT): |
2188 | 2200 |
|
2189 | 2201 | # unregister |
2190 | 2202 | zc.unregister_service(info) |
| 2203 | + zc.close() |
2191 | 2204 |
|
2192 | 2205 |
|
2193 | 2206 | def test_dns_compression_rollback_for_corruption(): |
|
0 commit comments