[TEST] Add tests for TriangleDisplay.#825
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #825 +/- ##
==========================================
+ Coverage 86.40% 87.38% +0.97%
==========================================
Files 86 86
Lines 4959 5200 +241
Branches 642 717 +75
==========================================
+ Hits 4285 4544 +259
+ Misses 478 464 -14
+ Partials 196 192 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
My first impression is that |
|
I think we should keep it at that (for now), to be sure that the Triangle is displayed. The next step would be to actually see if the values in the representation are correct, but other functions handle the data, and fixing issues with those functions are more likely if the values are incorrect. If we actually do start seeing issues in the Jupyter output caused by |
|
i'm good with that. we should circle back before we migrate all our docs to rst. |
|
Added some testing for malformed HTML. I felt like even the parsing function would need its own test, so I added that too. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b146e62. Configure here.
| with pytest.raises(ImportError, match=r"heatmap\(\) requires IPython\."): | ||
| raa.heatmap() | ||
|
|
||
| importlib.reload(display_mod) |
There was a problem hiding this comment.
Module reload cleanup not guaranteed on test failure
Low Severity
The cleanup importlib.reload(display_mod) calls at the end of test_heatmap_no_ipython and test_display_import_fallback_when_ipython_missing are not wrapped in try/finally. If an assertion inside the with mock.patch.dict(...) block fails, the mock.patch.dict context manager restores sys.modules, but the module's global HTML stays None because the final importlib.reload is skipped. This leaves display_mod in a dirty state, causing cascading failures in later tests like test_heatmap_render that depend on HTML being available.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b146e62. Configure here.
henrydingliu
left a comment
There was a problem hiding this comment.
love the new tests for html integrity


Summary of Changes
Adds unit tests for
core.display.pyRelated GitHub Issue(s)
#824
Additional Context for Reviewers
Adds a fixture called empty_triangle because it's used multiple times.
uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)Note
Low Risk
Low risk: primarily adds test coverage and only changes runtime behavior by consistently raising
ImportErrorwhen IPython/HTMLis unavailable forheatmap().Overview
Adds extensive unit tests for
TriangleDisplayrendering and formatting, including_dimensionality,__repr__,_repr_html_,_get_format_str, semi-annual origin formatting, andheatmap()behavior.Adjusts
heatmap()to always raiseImportError(with updated message) when IPython’sHTMLhelper isn’t available, and adds anempty_trianglepytest fixture to reuse across tests.Reviewed by Cursor Bugbot for commit b146e62. Bugbot is set up for automated code reviews on this repo. Configure here.