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 new file mode 100644 index 0000000..d1ac327 --- /dev/null +++ b/tests/test_makeqctoolsreport.py @@ -0,0 +1,23 @@ +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() 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