8000 Update dot_parser.HTML and add tests by ferdnyc · Pull Request #452 · pydot/pydot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update dot_parser.HTML and add tests #452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2025
Merged

Conversation

ferdnyc
Copy link
Member
@ferdnyc ferdnyc commented Jan 28, 2025

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 complete graphparser. 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:

  1. The pyparsing.lineno import went missing. (Ruff removed it.)
  2. ...because the exception message for the HTML class was missing the f on its (non-)f-string, which means the {lineno()} call wasn't being interpreted as Python code.
  3. And it was also missing a space between two words (where it was split into two strings).

So, this PR fixes those things, and adds a new test file test/test_parser.py, which currently contains only some pytest tests for pydot.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).

Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/pydot
  dot_parser.py
  test
  test_parser.py
Project Total  

This report was generated by python-coverage-comment-action

@lkk7
Copy link
Member
lkk7 commented Jan 29, 2025

... Yeah, that shows how much my "sanity check" is worth, especially when I wasn't fully focused on it. Thanks for the fix.

@lkk7 lkk7 merged commit c892d11 into pydot:main Jan 29, 2025
22 checks passed
@ferdnyc ferdnyc deleted the html-err-formatting branch January 29, 2025 23:15
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
0