Skip to content

Tests: script coverage, THD paths, subprocess PYTHONPATH, thd_analyzer fix#41

Draft
endolith wants to merge 1 commit into
masterfrom
cursor/issue-10-tests-7a0b
Draft

Tests: script coverage, THD paths, subprocess PYTHONPATH, thd_analyzer fix#41
endolith wants to merge 1 commit into
masterfrom
cursor/issue-10-tests-7a0b

Conversation

@endolith
Copy link
Copy Markdown
Owner

@endolith endolith commented May 12, 2026

Addresses #10 (adds and strengthens tests; does not reach 100% repo-wide coverage).

Summary

  • Bug fix: scripts/thd_analyzer.py called sys.exit from thd_analyzer() when no files were given, but sys was only imported under if __name__ == '__main__', so the Windows launcher (from thd_analyzer import thd_analyzer) could hit NameError. Import sys at module scope.
  • Subprocess tests: tests/subprocess_helpers.py sets PYTHONPATH to the repository root so measure_freq.py / wave_analyzer.py subprocess tests work without pip install -e . (CI already installs the package; this matches local runs).
  • New coverage: tests/test_scripts_invoked.py loads scripts with importlib, uses runpy for measure_freq __main__ and launcher scripts (with fake tkinter modules), and exercises wave_analyzer analyze branches, GUI display paths, and error exits.
  • waveform_analysis: test_thd.py covers THDN(..., weight='A') and THD(..., verbose=True); test_common.py covers scipy int32 PCM scaling when the scipy wavfile backend is active.

Combined waveform_analysis + scripts coverage in a single run is about 93% (remaining gaps are mostly optional backends: soundfile-only _common paths, matplotlib missing in histogram, and launcher ImportError fallbacks).

Open in Web Open in Cursor 

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants