diff options
| author | Brianna Rainey | 2026-01-29 14:50:29 -0500 |
|---|---|---|
| committer | GitHub | 2026-01-29 14:50:29 -0500 |
| commit | 71a22c6a121d1294a05ef35020c525fa70cae2fd (patch) | |
| tree | 025dd2329c214a5fe5ac78c7f2e8342e2bfde14d /tests/__init__.py | |
| parent | f66eb99465c61232a7f649e66bee59504bb0e52c (diff) | |
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
Diffstat (limited to 'tests/__init__.py')
| -rw-r--r-- | tests/__init__.py | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/tests/__init__.py b/tests/__init__.py index b615681..df08c7c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,8 +1,9 @@ import os import numpy -# core always has to be imported first -import avp.core +from avp.core import Core +from avp.command import Command +from avp.gui.mainwindow import MainWindow from avp.toolkit.ffmpeg import readAudioFile from pytest import fixture @@ -10,16 +11,47 @@ from pytest import fixture @fixture def audioData(): """Fixture that gives a tuple of (completeAudioArray, duration)""" - soundFile = getTestDataPath("test.ogg") + # Core.storeSettings() needed to store ffmpeg bin location + initCore() + soundFile = getTestDataPath("inputfiles/test.ogg") yield readAudioFile(soundFile, MockVideoWorker()) -def getTestDataPath(filename): +@fixture +def command(qtbot): + initCore() + command = Command() + command.quit = lambda _: None + yield command + + +@fixture +def window(qtbot): + initCore() + window = MainWindow(None, None) + window.clear() + qtbot.addWidget(window) + window.settings.setValue("outputWidth", 1920) + window.settings.setValue("outputHeight", 1080) + yield window + + +def getTestDataPath(filename=""): """Get path to a file in the ./data directory""" tests_dir = os.path.dirname(os.path.abspath(__file__)) return os.path.join(tests_dir, "data", filename) +def initCore(): + testDataDir = getTestDataPath() + unwanted = ["autosave.avp", "settings.ini"] + for file in unwanted: + filename = os.path.join(testDataDir, "autosave.avp") + if os.path.exists(filename): + os.remove(filename) + Core.storeSettings(testDataDir) + + class MockSignal: """Pretends to be a pyqtSignal""" |
