From e6842da24f3d63db3fe8ea8d6af3cf4773eb119d Mon Sep 17 00:00:00 2001 From: Henry Borchers Date: Fri, 6 Dec 2024 12:39:20 -0600 Subject: [PATCH 1/2] add test suite files for overcatch.py and makeqctoolsreport.py --- tests/test_makeqctoolsreport.py | 5 +++++ tests/test_overcatch.py | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 tests/test_makeqctoolsreport.py create mode 100644 tests/test_overcatch.py diff --git a/tests/test_makeqctoolsreport.py b/tests/test_makeqctoolsreport.py new file mode 100644 index 0000000..12c672e --- /dev/null +++ b/tests/test_makeqctoolsreport.py @@ -0,0 +1,5 @@ +# Note: This is currently an empy test suite and contains no actual tests. +# Until tests are written, it still serves the purpose to see if the module can +# be imported. + +from qct_parse import makeqctoolsreport diff --git a/tests/test_overcatch.py b/tests/test_overcatch.py new file mode 100644 index 0000000..e8422ab --- /dev/null +++ b/tests/test_overcatch.py @@ -0,0 +1,5 @@ +# Note: This is currently an empy test suite and contains no actual tests. +# Until tests are written, it still serves the purpose to see if the module can +# be imported. + +from qct_parse import overcatch \ No newline at end of file From fdca877c1c4487e150843e6fe82b8de2c2200421 Mon Sep 17 00:00:00 2001 From: Henry Borchers Date: Fri, 6 Dec 2024 12:57:41 -0600 Subject: [PATCH 2/2] make makeqctoolsreport script work with python 3.12+ --- qct_parse/makeqctoolsreport.py | 5 ++--- tests/test_makeqctoolsreport.py | 26 ++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/qct_parse/makeqctoolsreport.py b/qct_parse/makeqctoolsreport.py index f06103e..c529ecb 100644 --- a/qct_parse/makeqctoolsreport.py +++ b/qct_parse/makeqctoolsreport.py @@ -8,7 +8,6 @@ import gzip import shutil import argparse -from distutils import spawn #Context manager for changing the current working directory class cd: @@ -26,7 +25,7 @@ def __exit__(self, etype, value, traceback): def dependencies(): depends = ['ffmpeg','ffprobe'] for d in depends: - if spawn.find_executable(d) is None: + if shutil.which(d) is None: print("Buddy, you gotta install " + d) sys.exit() return @@ -134,6 +133,7 @@ def makeReport(startObj, outPath): os.remove(startObj + '.temp1.nut') def main(): + dependencies() ####init the stuff from the cli######## parser = argparse.ArgumentParser(description="parses QCTools XML files for frames beyond broadcast values") parser.add_argument('-i','--input',dest='i',help="the path to the input video file") @@ -164,6 +164,5 @@ def main(): startObj = startObj + ".temp1.nut" makeReport(startObj,outPath) -dependencies() if __name__ == '__main__': main() \ No newline at end of file diff --git a/tests/test_makeqctoolsreport.py b/tests/test_makeqctoolsreport.py index 12c672e..d1ac327 100644 --- a/tests/test_makeqctoolsreport.py +++ b/tests/test_makeqctoolsreport.py @@ -1,5 +1,23 @@ -# Note: This is currently an empy test suite and contains no actual tests. -# Until tests are written, it still serves the purpose to see if the module can -# be imported. - +import pytest from qct_parse import makeqctoolsreport + +def test_dependencies_found(monkeypatch): + # Simulate finding application by monkeypatching the which() command with a + # valid string + monkeypatch.setattr( + makeqctoolsreport.shutil, + 'which', + lambda *path: path + ) + assert makeqctoolsreport.dependencies() is None + +def test_dependencies_not_found_calls_system_exit(monkeypatch): + # Simulate not finding application + monkeypatch.setattr( + makeqctoolsreport.shutil, + 'which', + lambda *path: None + ) + + with pytest.raises(SystemExit): + makeqctoolsreport.dependencies()