Mock webbrowser.open() in test_dotfile to stop popping up a PDF - #9
Merged
Merged
Conversation
showgraph() calls webbrowser.open() on the rendered PDF, which was launching a real PDF viewer/browser window every test run -- purely incidental, since the test made no assertion on the result at all. Mocks webbrowser.open() so the test runs headless, and replaces the "doesn't crash" smoke test with a real assertion: the file webbrowser.open() was called with actually exists and starts with the PDF magic bytes (%PDF-), confirming dot's rendering pipeline genuinely produced a valid PDF -- a stronger check than before, not a weaker one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
test_dotfile() exercises the real dot->PDF rendering path via showgraph(), but only the docs job installed graphviz -- unittest and codecov didn't, so `dot` was silently missing there. The previous version of this test had no assertion on the result, so this went unnoticed; the new assertion (mock_open.assert_called_once(), added in this same PR) correctly caught it: CI failed with "dot: not found", showgraph()'s subprocess call returned nonzero, and webbrowser.open() was consequently never reached. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9 +/- ##
==========================================
+ Coverage 85.20% 85.33% +0.13%
==========================================
Files 2 2
Lines 750 750
==========================================
+ Hits 639 640 +1
+ Misses 111 110 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
showgraph()callswebbrowser.open()on the rendered PDF, which was launching a real PDF viewer/browser window every test run -- purely incidental, since the test made no assertion on the result at all.webbrowser.open()so the test runs headless, and replaces the "doesn't crash" smoke test with a real assertion: the filewebbrowser.open()was called with actually exists and starts with the PDF magic bytes (%PDF-), confirmingdot's rendering pipeline genuinely produced a valid PDF -- a stronger check than before, not a weaker one.Test plan
test_dotfilepasses headless, no popup