diff options
| author | Brianna Rainey | 2026-01-22 16:29:46 -0500 |
|---|---|---|
| committer | GitHub | 2026-01-22 16:29:46 -0500 |
| commit | a12be862e22bdec6a243a3f0b5f4f28d69084a2a (patch) | |
| tree | 7f2b21f58cf54deb81bfe77d7ef45358c80454f0 /tests/__init__.py | |
| parent | 36760579a0ae604074034c4b78cda2e3f3b001de (diff) | |
fix #89 with Image component v2.0 + 23 tests (#90)
* qtbot is needed in any test that uses a QObject
previously these tests would fail if they ran before qtbot was initialized by another test. I'm now running tests in a random order
* add tests for drawBars, readAudioFile, BlankFrame
* replace numpy.seterr with numpy.errstate
* fix incorrect comment
* add MockVideoWorker and imageDataSum
* test further into visualization (less likely to be a false positive)
* test FloodFrame function
* add failing test for Image component
one step towards fixing #89
* test component name CLI parsing
* prevent log warning when 1 setting changed
* correct tests to use widgets when needed
* test undo and blockSignals
* remove stretch_scale (use scale only)
* image ignores scale if stretch checkbox checked
fixes #89
* test Title Text component, ffmpeg command
* Image v2: replace stretched setting with resizeMode
3 resize modes are scale, cover, and stretch. Scale only applies when resizeMode is set to scale. Cover uses ImageOps.fit() to stretch while maintaining aspect ratio. Also, spinBox_scale was moved to be underneath comboBox_resizeMode.
* change transformData into staticmethod
the purpose is to allow easier reuse in other components
* add respondToAudio option to Image component
this causes the image to scale up and down slightly based on the input audio file
* cache static portion of image when animating
increases rendering speed of a 1-minute video by 12 seconds (based on two manual tests anyway)
Diffstat (limited to 'tests/__init__.py')
| -rw-r--r-- | tests/__init__.py | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/tests/__init__.py b/tests/__init__.py index d0073ef..b615681 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,27 +1,39 @@ -import pytest import os -import sys +import numpy + +# core always has to be imported first +import avp.core +from avp.toolkit.ffmpeg import readAudioFile +from pytest import fixture + + +@fixture +def audioData(): + """Fixture that gives a tuple of (completeAudioArray, duration)""" + soundFile = getTestDataPath("test.ogg") + yield readAudioFile(soundFile, MockVideoWorker()) 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 run(logFile): - """Run Pytest, which then imports and runs all tests in this module.""" - os.environ["PYTEST_QT_API"] = "PyQt6" - with open(logFile, "w") as f: - # temporarily redirect stdout to a text file so we capture pytest's output - sys.stdout = f - try: - val = pytest.main( - [ - os.path.dirname(__file__), - "-s", # disable pytest's internal capturing of stdout etc. - ] - ) - finally: - sys.stdout = sys.__stdout__ - - return val +class MockSignal: + """Pretends to be a pyqtSignal""" + + def emit(self, *args): + pass + + +class MockVideoWorker: + """Pretends to be a video thread worker""" + + progressBarSetText = MockSignal() + progressBarUpdate = MockSignal() + + +def imageDataSum(image): + """Get sum of raw data of a Pillow Image object""" + return numpy.asarray(image, dtype="int32").sum(dtype="int32") |
