Repository navigation
fix: keep FileNotFoundError catching a missing Graphviz dot - #680
Merged
Merged
Conversation
GraphvizError replaced pydot's FileNotFoundError for a missing dot in 3.2.2, which breaks code that skips diagrams with except FileNotFoundError. A missing program now raises GraphvizNotFoundError, a subclass of both GraphvizError and FileNotFoundError with errno ENOENT. Refs #672, #649 Signed-off-by: Fernando Macedo <fgmacedo@gmail.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #680 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 53 53
Lines 5787 5793 +6
Branches 918 918
=========================================
+ Hits 5787 5793 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ 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.



Why
Before 3.2.2, a missing
dotraised pydot 4.0.1'sFileNotFoundError('[Errno 2] "dot" not found in path.')(checked withPATH=/nonexistenton pydot 4.0.1). #672 replaced it withGraphvizError(StateMachineError), soexcept FileNotFoundErroraround diagram generation would stop catching a missing Graphviz in a patch release.What changes
GraphvizNotFoundError, a subclass of bothGraphvizErrorandFileNotFoundError, witherrno == ENOENT.str()is the same message fix: report Graphviz stderr when dot fails to render a diagram #672 introduced.GraphvizNotFoundErroris exported fromstatemachine.contrib.diagramnext toGraphvizError.dotthat exists but cannot run, or that exits non-zero, still raises a plainGraphvizError, which is not anOSError.docs/diagram.mddocuments both ways to catch it (with a doctest), and the Dot and svg diagrams fail to generate without useful error message #649 entry indocs/releases/3.2.2.mdmentions the subclass.Evidence
New tests run with
dotremoved fromPATH(monkeypatch.setenv("PATH", tmp_path)) throughrun_graphvizandformat(sm, "svg"). They assertpytest.raises(FileNotFoundError),isinstanceofGraphvizNotFoundErrorandGraphvizError,errno, and the exact message.Not verified
FileNotFoundErrorfor a missing executable there as well, so it should take the same branch.strerrorandargsdiffer from pydot's old exception (strerrorisNoneandargs == (message,), where pydot gave(2, message)). Only theexcept FileNotFoundErroranderrnocontracts are kept.Refs #672
Refs #649