From df724718e9a5caad47cbfb44f7bcf7f1470fee60 Mon Sep 17 00:00:00 2001 From: Color Dumper <156731588+ColorDumper@users.noreply.github.com> Date: Wed, 18 Nov 2026 15:23:37 -0500 Subject: [PATCH] Use documentation-only network addresses in the tests --- tests/fake_obs.py | 2 +- tests/test_config.py | 20 ++++++++++---------- tests/test_controller.py | 12 ++++++------ tests/test_fieldlog.py | 2 +- tests/test_logs.py | 2 +- tests/test_obs.py | 14 +++++++------- tests/test_overlay.py | 10 +++++----- tests/test_qt_backend.py | 32 ++++++++++++++++---------------- tests/test_qt_drawer.py | 4 ++-- tests/test_qt_status.py | 2 +- tests/test_qt_view.py | 2 +- tests/test_state.py | 4 ++-- 12 files changed, 53 insertions(+), 53 deletions(-) diff --git a/tests/fake_obs.py b/tests/fake_obs.py index 3d28dac..e917988 100644 --- a/tests/fake_obs.py +++ b/tests/fake_obs.py @@ -37,7 +37,7 @@ def scenario(s): def make_config(**overrides): values = { - "host": "10.0.0.2", + "host": "192.0.2.2", "port": 4455, "password": "", "scene_item_name": OVERLAY, diff --git a/tests/test_config.py b/tests/test_config.py index c13b875..68c6534 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -23,7 +23,7 @@ ) BASE = { - "host": "10.0.0.2", + "host": "192.0.2.2", "port": 4455, "password": "secret", "scene_item_name": "Overlay", @@ -129,7 +129,7 @@ def test_a_config_file_holding_null_is_unreadable(tmp_path): def test_save_then_load_round_trips(tmp_path): path = tmp_path / "config.json" cfg = AppConfig.from_dict( - {**default_config().to_dict(), "host": "10.0.0.5", "scene_item_name": "Map"} + {**default_config().to_dict(), "host": "192.0.2.5", "scene_item_name": "Map"} ) save_config(cfg, path) assert load_config(path) == cfg @@ -137,7 +137,7 @@ def test_save_then_load_round_trips(tmp_path): def test_a_save_cut_short_leaves_the_old_settings_intact(tmp_path, monkeypatch): path = tmp_path / "config.json" - old = AppConfig.from_dict({**default_config().to_dict(), "host": "10.0.0.5"}) + old = AppConfig.from_dict({**default_config().to_dict(), "host": "192.0.2.5"}) save_config(old, path) def dump_then_fail(data, file, **_options): @@ -145,7 +145,7 @@ def dump_then_fail(data, file, **_options): raise OSError("disk full") monkeypatch.setattr(config_module.json, "dump", dump_then_fail) - new = AppConfig.from_dict({**default_config().to_dict(), "host": "192.168.1.9"}) + new = AppConfig.from_dict({**default_config().to_dict(), "host": "198.51.100.9"}) with pytest.raises(OSError): save_config(new, path) @@ -160,7 +160,7 @@ def test_a_save_waits_out_something_holding_the_file_for_a_moment(tmp_path): # scanner or backup tool reading the file would. path = tmp_path / "config.json" save_config(default_config(), path) - new = AppConfig.from_dict({**default_config().to_dict(), "host": "192.168.1.9"}) + new = AppConfig.from_dict({**default_config().to_dict(), "host": "198.51.100.9"}) held = open(path, "rb") # noqa: SIM115 - closed by the timer below release = threading.Timer(0.2, held.close) release.start() @@ -176,10 +176,10 @@ def test_a_save_waits_out_something_holding_the_file_for_a_moment(tmp_path): def test_a_file_held_for_good_still_fails_and_keeps_the_old_settings(tmp_path, monkeypatch): path = tmp_path / "config.json" - old = AppConfig.from_dict({**default_config().to_dict(), "host": "10.0.0.5"}) + old = AppConfig.from_dict({**default_config().to_dict(), "host": "192.0.2.5"}) save_config(old, path) monkeypatch.setattr(config_module, "SAVE_RETRY_SECONDS", 0.01) - new = AppConfig.from_dict({**default_config().to_dict(), "host": "192.168.1.9"}) + new = AppConfig.from_dict({**default_config().to_dict(), "host": "198.51.100.9"}) with open(path, "rb"), pytest.raises(PermissionError): save_config(new, path) @@ -237,7 +237,7 @@ def test_to_loggable_dict_excludes_the_password_and_the_network_address(): # --- building settings from what a form holds --- FORM = { - "host": " 10.0.0.2 ", + "host": " 192.0.2.2 ", "port": " 4455 ", "password": " pass ", "scene_item_name": " Overlay ", @@ -255,7 +255,7 @@ def test_a_filled_in_form_becomes_settings(): cfg = config_from_form(**FORM) assert cfg == AppConfig( - host="10.0.0.2", + host="192.0.2.2", port=4455, password=" pass ", scene_item_name="Overlay", @@ -368,7 +368,7 @@ def test_checking_for_updates_is_on_unless_turned_off(tmp_path): ({"auto_connect": True}, False), ({"check_updates": False}, False), ({"hotkey": "M"}, True), - ({"host": "10.0.0.9"}, True), + ({"host": "192.0.2.9"}, True), ({"log_enabled": True}, True), ({"auto_reconnect": False}, True), ], diff --git a/tests/test_controller.py b/tests/test_controller.py index 267f2b4..0ff24da 100644 --- a/tests/test_controller.py +++ b/tests/test_controller.py @@ -37,7 +37,7 @@ def make_config(**overrides): values = { - "host": "10.0.0.2", + "host": "192.0.2.2", "port": 4455, "password": "", "scene_item_name": "Overlay", @@ -482,7 +482,7 @@ def test_the_test_button_is_passed_to_the_worker(h): assert h.service.manual_inputs == [True, False] -def run_check(h, check, host="10.0.0.2", port="4455", source=" Overlay "): +def run_check(h, check, host="192.0.2.2", port="4455", source=" Overlay "): results = [] controller = AppController(schedule=h.schedule, service=h.service, check=check) started = controller.check_connection(host, port, "pw", source, results.append) @@ -507,7 +507,7 @@ def check(host, port, password, source_name): assert controller.checking_connection is True finish_check(h, controller) - assert calls == [("10.0.0.2", 4455, "pw", "Overlay")] + assert calls == [("192.0.2.2", 4455, "pw", "Overlay")] assert results == [ConnectionCheck(ok=True, source_scene_count=2)] assert controller.checking_connection is False @@ -516,7 +516,7 @@ def test_a_connection_check_with_an_unusable_port_says_so_without_trying(h): controller = AppController(schedule=h.schedule, service=h.service, check=None) with pytest.raises(ValueError, match="OBS Port must be a number."): - controller.check_connection("10.0.0.2", "44a5", "", "", lambda _result: None) + controller.check_connection("192.0.2.2", "44a5", "", "", lambda _result: None) assert controller.checking_connection is False @@ -524,7 +524,7 @@ def test_test_link_refuses_a_port_out_of_range_without_trying(h): controller = AppController(schedule=h.schedule, service=h.service, check=None) with pytest.raises(ValueError, match="between 1 and 65535"): - controller.check_connection("10.0.0.2", "70000", "", "", lambda _result: None) + controller.check_connection("192.0.2.2", "70000", "", "", lambda _result: None) assert controller.checking_connection is False @@ -536,7 +536,7 @@ def slow_check(*_args): return ConnectionCheck(ok=True) controller, results, _ = run_check(h, slow_check) - assert controller.check_connection("10.0.0.2", "4455", "", "", results.append) is False + assert controller.check_connection("192.0.2.2", "4455", "", "", results.append) is False release.set() finish_check(h, controller) diff --git a/tests/test_fieldlog.py b/tests/test_fieldlog.py index aba4bc1..7ab5fc2 100644 --- a/tests/test_fieldlog.py +++ b/tests/test_fieldlog.py @@ -137,7 +137,7 @@ def test_a_stop_after_an_unexpected_error_says_so(): def test_no_connection_line_ever_names_the_obs_address(): # The window may be captured on stream, so the streaming PC's address # must not appear in it even if a message happens to mention it. - message = "Failed to connect to 192.168.1.42:4455" + message = "Failed to connect to 198.51.100.42:4455" for code in (EVENT_CONNECTED, EVENT_CONNECT_FAILED, EVENT_LINK_LOST, EVENT_STOPPED): assert "192.168" not in line(code, message).text diff --git a/tests/test_logs.py b/tests/test_logs.py index 2bd05fc..0995ac4 100644 --- a/tests/test_logs.py +++ b/tests/test_logs.py @@ -141,7 +141,7 @@ def test_describe_exception_gives_type_message_and_place_without_the_home_folder def test_describe_cause_names_the_underlying_failure_and_its_code(): try: try: - raise ConnectionResetError(10054, "reset by peer, host 10.0.0.2") + raise ConnectionResetError(10054, "reset by peer, host 192.0.2.2") except OSError as inner: raise RuntimeError("outer") from inner except RuntimeError as exc: diff --git a/tests/test_obs.py b/tests/test_obs.py index bc6398a..449a88f 100644 --- a/tests/test_obs.py +++ b/tests/test_obs.py @@ -40,7 +40,7 @@ def test_request_timeout_is_shorter_than_the_connect_timeout(): def test_connect_holds_the_long_timeout_then_shortens_the_socket(monkeypatch): monkeypatch.setattr(obs, "ReqClient", FakeReqClient) - client = connect_obs("10.0.0.2", 4455, "pw") + client = connect_obs("192.0.2.2", 4455, "pw") assert client.timeout == CONNECT_TIMEOUT assert client.base_client.ws.timeout == REQUEST_TIMEOUT @@ -56,7 +56,7 @@ def refuse(_value): self.base_client.ws.settimeout = refuse monkeypatch.setattr(obs, "ReqClient", Grumpy) - assert connect_obs("10.0.0.2", 4455, "pw") is not None + assert connect_obs("192.0.2.2", 4455, "pw") is not None class RaisingClient: @@ -124,7 +124,7 @@ def boom(**kwargs): monkeypatch.setattr(obs, "ReqClient", boom) with pytest.raises(expected): - connect_obs("10.0.0.2", 4455, "pw") + connect_obs("192.0.2.2", 4455, "pw") # --- the one-off connection check --------------------------------------------- @@ -139,7 +139,7 @@ def checked_obs(): def test_a_connection_check_counts_the_scenes_carrying_the_source(): fake = checked_obs() - result = obs.check_connection("10.0.0.2", 4455, "", "Overlay", connect=lambda *_: fake) + result = obs.check_connection("192.0.2.2", 4455, "", "Overlay", connect=lambda *_: fake) assert result == ConnectionCheck(ok=True, source_scene_count=2) assert fake.disconnected is True @@ -148,7 +148,7 @@ def test_a_connection_check_counts_the_scenes_carrying_the_source(): def test_a_connection_check_without_a_source_name_only_connects(): fake = checked_obs() - result = obs.check_connection("10.0.0.2", 4455, "", "", connect=lambda *_: fake) + result = obs.check_connection("192.0.2.2", 4455, "", "", connect=lambda *_: fake) assert result == ConnectionCheck(ok=True) assert fake.calls == [] @@ -159,7 +159,7 @@ def test_a_failed_connection_check_gives_the_reason(): def refuse(*_args): raise ObsAuthError(obs.OBS_BAD_PASSWORD) - result = obs.check_connection("10.0.0.2", 4455, "wrong", "Overlay", connect=refuse) + result = obs.check_connection("192.0.2.2", 4455, "wrong", "Overlay", connect=refuse) assert result == ConnectionCheck(ok=False, message=obs.OBS_BAD_PASSWORD) @@ -168,7 +168,7 @@ def test_a_check_that_fails_after_connecting_still_disconnects(): fake = checked_obs() fake.rule("GetSceneList", raises=OBSSDKTimeoutError("timed out")) - result = obs.check_connection("10.0.0.2", 4455, "", "Overlay", connect=lambda *_: fake) + result = obs.check_connection("192.0.2.2", 4455, "", "Overlay", connect=lambda *_: fake) assert result == ConnectionCheck(ok=False, message=obs.OBS_LINK_LOST) assert fake.disconnected is True diff --git a/tests/test_overlay.py b/tests/test_overlay.py index 50093a4..25a65d5 100644 --- a/tests/test_overlay.py +++ b/tests/test_overlay.py @@ -41,7 +41,7 @@ def at(ms): def hold_config(hide_delay_ms=120): return AppConfig( - host="10.0.0.2", + host="192.0.2.2", port=4455, password="", scene_item_name="Overlay", @@ -295,7 +295,7 @@ def fail_fast(host, port, password): monkeypatch.setattr(overlay_module, "connect_obs", fail_fast) cfg = AppConfig( - host="10.0.0.2", + host="192.0.2.2", port=4455, password="wrong", scene_item_name="Overlay", @@ -325,7 +325,7 @@ def fail_fast(host, port, password): service = MapHideService() service._running = True cfg = AppConfig( - host="10.0.0.2", + host="192.0.2.2", port=4455, password="wrong", scene_item_name="Overlay", @@ -359,7 +359,7 @@ def fail_fast(host, port, password): service = MapHideService() service._running = True cfg = AppConfig( - host="10.0.0.2", + host="192.0.2.2", port=4455, password="super secret", scene_item_name="Overlay", @@ -375,7 +375,7 @@ def fail_fast(host, port, password): contents = (tmp_path / "maphide-debug.log").read_text(encoding="utf-8") assert "Overlay" in contents assert "hotkey=M" in contents - assert "10.0.0.2" not in contents + assert "192.0.2.2" not in contents assert "super secret" not in contents diff --git a/tests/test_qt_backend.py b/tests/test_qt_backend.py index bd290b2..0d4796e 100644 --- a/tests/test_qt_backend.py +++ b/tests/test_qt_backend.py @@ -106,7 +106,7 @@ def h(): def fill_form(backend, **values): - defaults = {"host": "10.0.0.2", "port": "4455", "scene_item_name": "Overlay"} + defaults = {"host": "192.0.2.2", "port": "4455", "scene_item_name": "Overlay"} for name, value in {**defaults, **values}.items(): backend.setField(name, value) @@ -118,9 +118,9 @@ def save_form(backend, **values): def test_loading_fills_the_form_from_the_saved_settings(h): - h.load(lambda: make_config(host="10.0.0.9", port=4456)) + h.load(lambda: make_config(host="192.0.2.9", port=4456)) - assert h.backend.form["host"] == "10.0.0.9" + assert h.backend.form["host"] == "192.0.2.9" assert h.backend.form["port"] == "4456" @@ -139,21 +139,21 @@ def run_scheduled(h): def test_connect_on_startup_starts_maphide_with_the_saved_settings(h): - h.load(lambda: make_config(host="10.0.0.9", auto_connect=True, check_updates=False)) + h.load(lambda: make_config(host="192.0.2.9", auto_connect=True, check_updates=False)) assert h.service.started_with == [] run_scheduled(h) - assert [cfg.host for cfg in h.service.started_with] == ["10.0.0.9"] + assert [cfg.host for cfg in h.service.started_with] == ["192.0.2.9"] def test_connect_on_startup_ignores_an_edit_made_before_it_starts(h): - h.load(lambda: make_config(host="10.0.0.9", auto_connect=True, check_updates=False)) - fill_form(h.backend, host="10.0.0.5") + h.load(lambda: make_config(host="192.0.2.9", auto_connect=True, check_updates=False)) + fill_form(h.backend, host="192.0.2.5") run_scheduled(h) - assert [cfg.host for cfg in h.service.started_with] == ["10.0.0.9"] + assert [cfg.host for cfg in h.service.started_with] == ["192.0.2.9"] def test_maphide_waits_for_start_when_connect_on_startup_is_off(h): @@ -211,7 +211,7 @@ def test_saving_writes_the_form_and_says_so(h): h.backend.save() - assert h.saved[-1].host == "10.0.0.2" + assert h.saved[-1].host == "192.0.2.2" assert h.saves == [True] assert h.lines[-1][1] == "> settings saved" @@ -294,12 +294,12 @@ def test_start_ignores_and_never_saves_unsaved_changes(h): def test_closing_settings_puts_the_saved_settings_back(h): save_form(h.backend, hotkey="M") - h.backend.setField("host", "192.168.1.50") + h.backend.setField("host", "198.51.100.50") h.backend.setField("hotkey", "K") h.backend.discardChanges() - assert h.backend.form["host"] == "10.0.0.2" + assert h.backend.form["host"] == "192.0.2.2" assert h.backend.form["hotkey"] == "M" assert h.backend.hasUnsavedChanges is False @@ -328,8 +328,8 @@ def test_a_change_counts_as_unsaved_until_saved(h): def test_changing_a_field_back_is_not_an_unsaved_change(h): save_form(h.backend) - h.backend.setField("host", "192.168.1.50") - h.backend.setField("host", "10.0.0.2") + h.backend.setField("host", "198.51.100.50") + h.backend.setField("host", "192.0.2.2") assert h.backend.hasUnsavedChanges is False @@ -337,7 +337,7 @@ def test_changing_a_field_back_is_not_an_unsaved_change(h): def test_spaces_around_a_value_are_not_an_unsaved_change(h): save_form(h.backend) - h.backend.setField("host", " 10.0.0.2 ") + h.backend.setField("host", " 192.0.2.2 ") assert h.backend.hasUnsavedChanges is False @@ -352,7 +352,7 @@ def test_a_captured_key_is_an_unsaved_change(h): def test_reset_leaves_nothing_unsaved(h): save_form(h.backend) - h.backend.setField("host", "192.168.1.50") + h.backend.setField("host", "198.51.100.50") h.backend.resetDefaults() @@ -396,7 +396,7 @@ def test_test_link_reports_the_scenes_carrying_the_source(h): assert h.backend.testState == "busy" h.run_check() - assert h.checks == [("10.0.0.2", 4455, "", "Overlay")] + assert h.checks == [("192.0.2.2", 4455, "", "Overlay")] assert h.backend.testState == "ok" assert h.backend.sourceText == f"Found in 3 scenes. {SOURCE_FOLLOWS}" diff --git a/tests/test_qt_drawer.py b/tests/test_qt_drawer.py index 2902727..fb96971 100644 --- a/tests/test_qt_drawer.py +++ b/tests/test_qt_drawer.py @@ -17,7 +17,7 @@ from maphide.qt.app import Backend, build_window # noqa: E402 from maphide.qt.view import RESET_DISCONNECTS, RESET_STOPS # noqa: E402 -SAVED = {"host": "10.0.0.2", "port": "4455", "scene_item_name": "Overlay"} +SAVED = {"host": "192.0.2.2", "port": "4455", "scene_item_name": "Overlay"} @pytest.fixture @@ -89,7 +89,7 @@ def test_typing_in_a_field_changes_the_form(setup): type_into(window, host_field(window), "9") - assert backend.form["host"] == "10.0.0.29" + assert backend.form["host"] == "192.0.2.29" def test_closing_settings_puts_the_typed_field_back(setup): diff --git a/tests/test_qt_status.py b/tests/test_qt_status.py index ac4a8ea..771938d 100644 --- a/tests/test_qt_status.py +++ b/tests/test_qt_status.py @@ -31,7 +31,7 @@ def setup(qt_app): def connect(backend, service, scene, **settings): - form = {"host": "10.0.0.2", "port": "4455", "scene_item_name": "Overlay", **settings} + form = {"host": "192.0.2.2", "port": "4455", "scene_item_name": "Overlay", **settings} for name, value in form.items(): backend.setField(name, value) backend.save() diff --git a/tests/test_qt_view.py b/tests/test_qt_view.py index aa58613..281543d 100644 --- a/tests/test_qt_view.py +++ b/tests/test_qt_view.py @@ -237,7 +237,7 @@ def test_a_last_shown_entry_that_dropped_off_means_all_are_new(): def test_the_form_round_trips_a_config(): - cfg = replace(default_config(), host="10.0.0.2", port=4456, scene_item_name="Overlay") + cfg = replace(default_config(), host="192.0.2.2", port=4456, scene_item_name="Overlay") values = form_values(cfg) diff --git a/tests/test_state.py b/tests/test_state.py index 8267f59..30eef8d 100644 --- a/tests/test_state.py +++ b/tests/test_state.py @@ -15,7 +15,7 @@ def at(ms): def hold_config(hide_delay_ms=120): return AppConfig( - host="10.0.0.2", + host="192.0.2.2", port=4455, password="", scene_item_name="Overlay", @@ -28,7 +28,7 @@ def hold_config(hide_delay_ms=120): def toggle_config(hotkey="M", hide_hotkey="M", hide_delay_ms=120): return AppConfig( - host="10.0.0.2", + host="192.0.2.2", port=4455, password="", scene_item_name="Overlay",