Update dot_parser.HTML and add tests #452
Merged
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.
I'm an idiot.
And, apologies to @davidweichiang for my being an idiot.
If I'd not been an idiot, I'd have realized that of course we can test the
HTML
parsing class, including its exception — just, not within the context of the completegraphparser
. We test it just like we'd unit test any other class: In isolation.If I'd realized that, and written (or asked for) some unit tests on the class, we'd have caught that:
pyparsing.lineno
import went missing. (Ruff removed it.)HTML
class was missing thef
on its (non-)f-string, which means the{lineno()}
call wasn't being interpreted as Python code.So, this PR fixes those things, and adds a new test file
test/test_parser.py
, which currently contains only some pytest tests forpydot.dot_parser.HTML
— both successful and failed parses. (The failed parse is where we can actually see its exception in use.)It also moves the class up to the top of the
dot_parser.py
file with the other classes, gives it a docstring, and shortens the exception message slightly (as it proved a bit unwieldy, in practice).