Skip to content

Commit 283d2f8

Browse files
authored
test: fix import order in test_cli_gui_run (#419)
1 parent 3e5b9a8 commit 283d2f8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tests/aignostics/cli_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ def test_cli_fails_on_invalid_setting_with_environ(runner) -> None:
129129

130130

131131
if find_spec("nicegui"):
132+
# Import module explicitly to ensure it's loaded before monkeypatching with string paths.
133+
# Without this, monkeypatch.setattr("aignostics.utils._gui...") fails in CI because
134+
# pytest-xdist workers may not have aignostics.utils loaded as an attribute yet.
135+
import aignostics.utils._gui as _utils_gui
132136

133137
@pytest.mark.integration
134138
def test_cli_gui_help(runner: CliRunner) -> None:
@@ -186,7 +190,7 @@ def mock_app_mount(path, app_instance):
186190

187191
# Apply the mocks
188192
monkeypatch.setattr("nicegui.ui.run", mock_ui_run)
189-
monkeypatch.setattr("aignostics.utils._gui.gui_register_pages", mock_gui_register_pages)
193+
monkeypatch.setattr(_utils_gui, "gui_register_pages", mock_gui_register_pages)
190194
monkeypatch.setattr("nicegui.app.mount", mock_app_mount)
191195

192196
# Create a mock for native_app.find_open_port()

0 commit comments

Comments
 (0)