| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,9 +20,9 @@ python-zeroconf | |||
| 20 | 20 | ||
| 21 | 21 | `Documentation <https://python-zeroconf.readthedocs.io/en/latest/>`_. | |
| 22 | 22 | ||
| 23 | - This is fork of pyzeroconf, Multicast DNS Service Discovery for Python, | ||
| 24 | - originally by Paul Scott-Murphy (https://github.com/paulsm/pyzeroconf), | ||
| 25 | - modified by William McBrine (https://github.com/wmcbrine/pyzeroconf). | ||
| 23 | + This project is a fork of pyzeroconf, originally by Paul Scott-Murphy | ||
| 24 | + (https://github.com/paulsm/pyzeroconf), modified by William McBrine | ||
| 25 | + (https://github.com/wmcbrine/pyzeroconf). | ||
| 26 | 26 | ||
| 27 | 27 | Compatible with: | |
| 28 | 28 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,7 +27,7 @@ | |||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | 29 | class RecordManager: | |
| 30 | - """Process records into the cache and notify listeners.""" | ||
| 30 | + """Apply incoming records to the cache and deliver the updates to listeners.""" | ||
| 31 | 31 | ||
| 32 | 32 | __slots__ = ("cache", "listeners", "zc") | |
| 33 | 33 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,32 +57,23 @@ async def make_query(): | |||
| 57 | 57 | asyncio.run_coroutine_threadsafe(make_query(), zc.loop).result() | |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | + @pytest.mark.parametrize("unicast", [False, True]) | ||
| 60 | 61 | @pytest.mark.parametrize("interfaces", [r.InterfaceChoice.All, r.InterfaceChoice.Default]) | |
| 61 | - def test_open_and_close_cleanly(interfaces): | ||
| 62 | - r.Zeroconf(interfaces=interfaces).close() | ||
| 62 | + def test_open_and_close_cleanly(interfaces: r.InterfaceChoice, unicast: bool) -> None: | ||
| 63 | + r.Zeroconf(interfaces=interfaces, unicast=unicast).close() | ||
| 63 | 64 | ||
| 64 | 65 | ||
| 65 | - def test_launch_and_close_context_manager(): | ||
| 66 | - with r.Zeroconf(interfaces=r.InterfaceChoice.All) as rv: | ||
| 67 | - assert rv.done is False | ||
| 68 | - assert rv.done is True | ||
| 69 | - | ||
| 70 | - with r.Zeroconf(interfaces=r.InterfaceChoice.Default) as rv: # type: ignore[unreachable] | ||
| 71 | - assert rv.done is False | ||
| 72 | - assert rv.done is True | ||
| 73 | - | ||
| 74 | - | ||
| 75 | - def test_launch_and_close_unicast(): | ||
| 76 | - rv = r.Zeroconf(interfaces=r.InterfaceChoice.All, unicast=True) | ||
| 77 | - rv.close() | ||
| 78 | - rv = r.Zeroconf(interfaces=r.InterfaceChoice.Default, unicast=True) | ||
| 79 | - rv.close() | ||
| 66 | + @pytest.mark.parametrize("interfaces", [r.InterfaceChoice.All, r.InterfaceChoice.Default]) | ||
| 67 | + def test_context_manager_marks_done(interfaces: r.InterfaceChoice) -> None: | ||
| 68 | + with r.Zeroconf(interfaces=interfaces) as zc: | ||
| 69 | + assert zc.done is False | ||
| 70 | + assert zc.done is True | ||
| 80 | 71 | ||
| 81 | 72 | ||
| 82 | 73 | def test_close_multiple_times(): | |
| 83 | - rv = r.Zeroconf(interfaces=r.InterfaceChoice.Default) | ||
| 84 | - rv.close() | ||
| 85 | - rv.close() | ||
| 74 | + zc = r.Zeroconf(interfaces=r.InterfaceChoice.Default) | ||
| 75 | + zc.close() | ||
| 76 | + zc.close() | ||
| 86 | 77 | ||
| 87 | 78 | ||
| 88 | 79 | def test_close_releases_owned_event_loop(): | |
@@ -93,11 +84,11 @@ def test_close_releases_owned_event_loop(): | |||
| 93 | 84 | Zeroconf construct/close cycle and the process eventually exhausts | |
| 94 | 85 | its FD limit. | |
| 95 | 86 | """ | |
| 96 | - rv = r.Zeroconf(interfaces=["127.0.0.1"]) | ||
| 97 | - loop = rv.loop | ||
| 87 | + zc = r.Zeroconf(interfaces=["127.0.0.1"]) | ||
| 88 | + loop = zc.loop | ||
| 98 | 89 | assert loop is not None | |
| 99 | 90 | assert loop.is_running() | |
| 100 | - rv.close() | ||
| 91 | + zc.close() | ||
| 101 | 92 | assert loop.is_closed() | |
| 102 | 93 | ||
| 103 | 94 | ||
@@ -123,38 +114,23 @@ def _fd_count() -> int: | |||
| 123 | 114 | ||
| 124 | 115 | @pytest.mark.skipif(not has_working_ipv6(), reason="Requires IPv6") | |
| 125 | 116 | @pytest.mark.skipif(os.environ.get("SKIP_IPV6"), reason="IPv6 tests disabled") | |
| 126 | - def test_launch_and_close_v4_v6(): | ||
| 127 | - rv = r.Zeroconf(interfaces=r.InterfaceChoice.All, ip_version=r.IPVersion.All) | ||
| 128 | - rv.close() | ||
| 129 | - with warnings.catch_warnings(record=True) as warned: | ||
| 130 | - rv = r.Zeroconf(interfaces=r.InterfaceChoice.Default, ip_version=r.IPVersion.All) | ||
| 131 | - rv.close() | ||
| 132 | - first_warning = warned[0] | ||
| 133 | - assert "IPv6 multicast requests can't be sent using default interface" in str(first_warning.message) | ||
| 134 | - | ||
| 135 | - | ||
| 136 | - @pytest.mark.skipif(not has_working_ipv6(), reason="Requires IPv6") | ||
| 137 | - @pytest.mark.skipif(os.environ.get("SKIP_IPV6"), reason="IPv6 tests disabled") | ||
| 138 | - def test_launch_and_close_v6_only(): | ||
| 139 | - rv = r.Zeroconf(interfaces=r.InterfaceChoice.All, ip_version=r.IPVersion.V6Only) | ||
| 140 | - rv.close() | ||
| 117 | + @pytest.mark.parametrize("ip_version", [r.IPVersion.All, r.IPVersion.V6Only]) | ||
| 118 | + def test_default_interface_warns_when_ipv6_requested(ip_version: r.IPVersion) -> None: | ||
| 119 | + r.Zeroconf(interfaces=r.InterfaceChoice.All, ip_version=ip_version).close() | ||
| 141 | 120 | with warnings.catch_warnings(record=True) as warned: | |
| 142 | - rv = r.Zeroconf(interfaces=r.InterfaceChoice.Default, ip_version=r.IPVersion.V6Only) | ||
| 143 | - rv.close() | ||
| 144 | - first_warning = warned[0] | ||
| 145 | - assert "IPv6 multicast requests can't be sent using default interface" in str(first_warning.message) | ||
| 121 | + r.Zeroconf(interfaces=r.InterfaceChoice.Default, ip_version=ip_version).close() | ||
| 122 | + assert "IPv6 multicast requests can't be sent using default interface" in str(warned[0].message) | ||
| 146 | 123 | ||
| 147 | 124 | ||
| 148 | 125 | @pytest.mark.skipif(sys.platform == "darwin", reason="apple_p2p failure path not testable on mac") | |
| 149 | - def test_launch_and_close_apple_p2p_not_mac(): | ||
| 126 | + def test_apple_p2p_rejected_off_mac(): | ||
| 150 | 127 | with pytest.raises(RuntimeError): | |
| 151 | 128 | r.Zeroconf(apple_p2p=True) | |
| 152 | 129 | ||
| 153 | 130 | ||
| 154 | 131 | @pytest.mark.skipif(sys.platform != "darwin", reason="apple_p2p happy path only testable on mac") | |
| 155 | - def test_launch_and_close_apple_p2p_on_mac(): | ||
| 156 | - rv = r.Zeroconf(apple_p2p=True) | ||
| 157 | - rv.close() | ||
| 132 | + def test_apple_p2p_binds_on_mac(): | ||
| 133 | + r.Zeroconf(apple_p2p=True).close() | ||
| 158 | 134 | ||
| 159 | 135 | ||
| 160 | 136 | def test_use_asyncio_false_forces_thread_when_loop_running(): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments