From f03a3a686c7304588dd434322c73506531e53595 Mon Sep 17 00:00:00 2001 From: Brianna Rainey Date: Thu, 12 Feb 2026 15:38:54 -0500 Subject: v2.2.4 - Quiet FFmpeg; add "invert" option to Classic Vis; fix CLI parsing for Image component (#96) * change noisiness of terminal output ffmpeg no longer prints everything into the terminal unless we're in `--verbose` mode. percentage progress text stays on one line while not in verbose mode. * Added hint to run `avp --verbose` if `avp --log` is run with no avp_debug.log file present * Classic Visualizer: add invert option * Image component: fix path commandline option * Image component: restrict file formats in CLI to match GUI * Color component: add tooltip to color2 picker (second color of gradients) * change tests to work with pytest-xdist avp core stores its config (location of `settings.ini`) in temp directories if using multiple workers to run tests, so they don't interfere with each other. when using a single worker, the `tests/data/config` directory is still used * check alt comp names when parsing cmdline * rename `original.py` to `classic.py` * move `component.py` into subpackage * rename comp_original to comp_classic * show traceback if renderFrame() raises exception * do not try to insert non-existent components from project files * add "composite" property for components if a component returns "composite" then it will receive a frame to draw on during calls to previewRender and frameRender * more tests of projects, actions, waveform, spectrum, image, color, classic * do not change presetDir to "projects" within PresetManager--- tests/__init__.py | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'tests/__init__.py') diff --git a/tests/__init__.py b/tests/__init__.py index bb35f72..b08a6bd 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,5 @@ import os +import tempfile import numpy from avp.core import Core @@ -8,10 +9,19 @@ from avp.toolkit.ffmpeg import readAudioFile from pytest import fixture +PYTEST_XDIST_WORKER_COUNT = os.environ.get("PYTEST_XDIST_WORKER_COUNT", 0) + + +@fixture +def settings(): + """Doesn't instantiate core: just calls a static method to store `settings.ini`""" + initCore() + yield None + + @fixture def audioData(): """Fixture that gives a tuple of (completeAudioArray, duration)""" - # Core.storeSettings() needed to store ffmpeg bin location initCore() soundFile = getTestDataPath("inputfiles/test.ogg") yield readAudioFile(soundFile, MockVideoWorker()) @@ -28,6 +38,8 @@ def command(qtbot): @fixture def window(qtbot): initCore() + # patch out any modal dialog that might happen + MainWindow.showMessage = lambda self, msg, **kwargs: print(msg) window = MainWindow(None, None) window.clear() qtbot.addWidget(window) @@ -43,13 +55,41 @@ def getTestDataPath(filename=""): def initCore(): - testDataDir = getTestDataPath("config") + """ + Initializes the Core by creating `settings.ini` + Returns the temp directory path where settings.ini was created + or None if multiple pytest workers are not enabled. + """ + try: + numWorkers = int(PYTEST_XDIST_WORKER_COUNT) + except ValueError: + numWorkers = 0 + if numWorkers > 0: + # use temporary directories for multiple workers + # so they don't interfere with each other + configDir = tempfile.mkdtemp(prefix="avp-config-") + else: + # use test data path so we can easily see it after + # a failed test, and help us understand the config + configDir = getTestDataPath("config") unwanted = ["autosave.avp", "settings.ini"] for file in unwanted: - filename = os.path.join(testDataDir, "autosave.avp") + filename = os.path.join(configDir, "autosave.avp") if os.path.exists(filename): os.remove(filename) - Core.storeSettings(testDataDir) + Core.storeSettings(configDir) + return configDir if numWorkers > 0 else None + + +def preFrameRender(audioData, comp): + """Prepares a component for calls to frameRender()""" + comp.preFrameRender( + audioFile=getTestDataPath("inputfiles/test.ogg"), + completeAudioArray=audioData[0], + sampleSize=1470, + progressBarSetText=MockSignal(), + progressBarUpdate=MockSignal(), + ) class MockSignal: -- cgit v1.2.3