Tests: script coverage, THD paths, subprocess PYTHONPATH, thd_analyzer fix#41
Draft
endolith wants to merge 1 commit into
Draft
Tests: script coverage, THD paths, subprocess PYTHONPATH, thd_analyzer fix#41endolith wants to merge 1 commit into
endolith wants to merge 1 commit into
Conversation
Fix thd_analyzer so empty invocations call sys.exit correctly when the launcher imports the module (sys was only imported under __main__). Add subprocess PYTHONPATH injection so measure_freq and wave_analyzer CLI tests find waveform_analysis without an editable install. Add direct script tests via importlib and runpy (including fake tkinter for Windows launchers), wave_analyzer analyze and error paths, THDN A-weighting, THD verbose logging, and scipy int32 PCM scaling in load(). Co-authored-by: endolith <endolith@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #10 (adds and strengthens tests; does not reach 100% repo-wide coverage).
Summary
scripts/thd_analyzer.pycalledsys.exitfromthd_analyzer()when no files were given, butsyswas only imported underif __name__ == '__main__', so the Windows launcher (from thd_analyzer import thd_analyzer) could hitNameError. Importsysat module scope.tests/subprocess_helpers.pysetsPYTHONPATHto the repository root someasure_freq.py/wave_analyzer.pysubprocess tests work withoutpip install -e .(CI already installs the package; this matches local runs).tests/test_scripts_invoked.pyloads scripts withimportlib, usesrunpyformeasure_freq__main__and launcher scripts (with faketkintermodules), and exerciseswave_analyzeranalyze branches, GUI display paths, and error exits.waveform_analysis:test_thd.pycoversTHDN(..., weight='A')andTHD(..., verbose=True);test_common.pycovers scipyint32PCM scaling when the scipy wavfile backend is active.Combined
waveform_analysis+scriptscoverage in a single run is about 93% (remaining gaps are mostly optional backends: soundfile-only_commonpaths, matplotlib missing inhistogram, and launcherImportErrorfallbacks).