Skip to content

Commit bc3a628

Browse files
committed
add test
1 parent ed9344e commit bc3a628

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

tests/test_asyncio.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ async def test_async_with_sync_passed_in_closed_in_async() -> None:
104104
@pytest.mark.asyncio
105105
async def test_sync_within_event_loop_executor() -> None:
106106
"""Test sync version still works from an executor within an event loop."""
107+
107108
def sync_code():
108109
zc = Zeroconf(interfaces=['127.0.0.1'])
109110
assert zc.get_service_info("_neverused._tcp.local.", "xneverused._neverused._tcp.local.", 10) is None

tests/test_dns.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,31 @@ def test_dns_service_record_hashablity():
288288
assert len(record_set) == 4
289289

290290

291+
def test_dns_nsec_record_hashablity():
292+
"""Test DNSNsec are hashable."""
293+
nsec1 = r.DNSNsec(
294+
'irrelevant', const._TYPE_PTR, const._CLASS_IN, const._DNS_OTHER_TTL, 'irrelevant', [1, 2, 3]
295+
)
296+
nsec2 = r.DNSNsec(
297+
'irrelevant', const._TYPE_PTR, const._CLASS_IN, const._DNS_OTHER_TTL, 'irrelevant', [1, 2]
298+
)
299+
300+
record_set = set([nsec1, nsec2])
301+
assert len(record_set) == 2
302+
303+
record_set.add(nsec1)
304+
assert len(record_set) == 2
305+
306+
nsec2_dupe = r.DNSNsec(
307+
'irrelevant', const._TYPE_PTR, const._CLASS_IN, const._DNS_OTHER_TTL, 'irrelevant', [1, 2]
308+
)
309+
assert nsec2 == nsec2_dupe
310+
assert nsec2.__hash__() == nsec2_dupe.__hash__()
311+
312+
record_set.add(nsec2_dupe)
313+
assert len(record_set) == 2
314+
315+
291316
def test_rrset_does_not_consider_ttl():
292317
"""Test DNSRRSet does not consider the ttl in the hash."""
293318

0 commit comments

Comments
 (0)