From 71a22c6a121d1294a05ef35020c525fa70cae2fd Mon Sep 17 00:00:00 2001 From: Brianna Rainey Date: Thu, 29 Jan 2026 14:50:29 -0500 Subject: v2.2.2 - fix flaky tests, fix UnboundLocalError in MainWindow.createNewProject (#94) * search more than one filename for compName * remove extra QVBoxLayout * insert default components using name instead of index * bump version 2.2.1 to 2.2.2 * tests do not use `.config` for settings Core.storeSettings() is no longer called as a side effect any time avp.core is imported. Thus the tests use a new `initCore` method and the normal user path now relies on entering via `cli.py`. This means certain toolkit functions (e.g., ones using `FFMPEG_BIN`) no longer work if imported from a different python script, unless they call Core.storeSettings() themselves to initialize the settings.ini file * fix UnboundLocalError in createNewProject--- tests/test_mainwindow_projects.py | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/test_mainwindow_projects.py (limited to 'tests/test_mainwindow_projects.py') diff --git a/tests/test_mainwindow_projects.py b/tests/test_mainwindow_projects.py new file mode 100644 index 0000000..8ad491a --- /dev/null +++ b/tests/test_mainwindow_projects.py @@ -0,0 +1,40 @@ +from pytest import fixture +from pytestqt import qtbot +from . import getTestDataPath, window + + +def test_mainwindow_clear(qtbot, window): + """MainWindow.clear() gives us a clean slate""" + assert len(window.core.selectedComponents) == 0 + + +def test_mainwindow_openProject(qtbot, window): + """Open testproject.avp using MainWindow.openProject()""" + window.openProject(getTestDataPath("projects/testproject.avp"), prompt=False) + assert len(window.core.selectedComponents) == 2 + + +def test_mainwindow_newProject_without_unsaved_changes(qtbot, window): + """Starting new project without unsaved changes""" + didCallFunction = False + + def captureFunction(*args, **kwargs): + nonlocal didCallFunction + didCallFunction = True + + window.createNewProject(prompt=False) + assert not didCallFunction + assert len(window.core.selectedComponents) == 0 + + +def test_mainwindow_newProject_with_unsaved_changes(qtbot, window): + """Starting new project with unsaved changes""" + didCallFunction = False + + def captureFunction(*args, **kwargs): + nonlocal didCallFunction + didCallFunction = True + + window.openSaveChangesDialog = captureFunction + window.createNewProject(prompt=True) + assert didCallFunction -- cgit v1.2.3