Skip to content

Conversation

@mshroyer
Copy link
Contributor

Stacked on top of #33

For #32, this modifies the existing tests to make them more amenable to supporting reStructuredText in addition to Markdown. At a high level:

  • Expected values are no longer determined implicitly within TestGraphviz, rather given explicitly in test cases alongside options and settings. I believe this will make the tests easier to read when RST support is added.
  • A test_md method is factored out of TestGraphviz, such that a corresponding test_rst can be added later.
  • BeautifulSoup is used to verify output, making the tests less dependent on the exact textual order of HTML attributes in the output. This helps with later adding RST support.

Given the changes to test_output, I verified the new behavior by intentionally breaking some pre-existing test cases and making sure they would actually fail if incorrect.

These aren't necessary for running the tests with `invoke tests`,
`pytest`, or `python -m unittest`, since these already "see" the test_
method from the base class.  Removing them simplifies extending the test
cases to also cover RST.
This changes how input, settings, and expected output are specified in
test cases.  Internal logic within the TestGraphviz base class is
removed, in favor of specifying all three of these explicitly.  Input
options are now given as a dict.

The main goal of this change is to make it easier to extend these
tests to cover RST too.  IMO this also makes it easier to read the tests
and understand which combination of settings and options are under test,
and what the expected output is.

A noteworthy side-effect of this change is that we now test the plugin's
behavior in the case that no GRAPHVIZ_* settings are specificed, except
those explicitly overridden in test cases.
Factors writing the input file and running Pelican out of setUp(), so
that a corresponding test_rst can be added to the base class.
Using BeautifulSoup instead of regular expressions lets us assert that
the expected elements are found with the right classes and attributes,
without hard-coding whether e.g. `alt` is the first attribute written in
the `img` tag.

This will enable using these same assertions over HTML generated by
ET.tostring in the RST implementation.
@mshroyer mshroyer marked this pull request as ready for review October 27, 2025 13:36
f"""
{block_start}{f" [{options}] " if options else " "}dot
digraph {digraph_id if digraph_id else ""} {{
md_input = f"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer not defining a variable here (md_input) and using directly fid.write with the f-string as argument. But this is a stylistic issue. YMMV

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@rlaboiss
Copy link
Collaborator

rlaboiss commented Nov 2, 2025

I think I finished the review of this PR. If you can address my remarks in the code, it will be great!

- Add copyright line
- Break setUp parameters into config, settings, and expected
- Remove md_input variable
- Use variables to avoid repeating constants in test cases
Copy link
Contributor Author

@mshroyer mshroyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! I think I've addressed the comments here, let me know if I'm missing anything.

I wasn't able to compose my fixes into separate fixup! commits that could both be appended to this PR and then auto-squashed onto the original commits to create a clean stack before merging. Instead, I've added a single commit addressing these change requests, as I wasn't sure what force-pushing amendments of the original commits to this branch would have done to our review history.

(If you'd prefer I push an amended version of the original stack, though, that wouldn't be difficult for me to do instead.)

f"""
{block_start}{f" [{options}] " if options else " "}dot
digraph {digraph_id if digraph_id else ""} {{
md_input = f"""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

I accidentally missed paramterizing one of the setUp() parameters as
requested in the previous code review.  This fixes it.
@rlaboiss
Copy link
Collaborator

rlaboiss commented Nov 3, 2025

Let us keep the current history. I am going to merge your PR. Thanks for the meticulous work!

@rlaboiss rlaboiss merged commit 0bdb7a3 into pelican-plugins:main Nov 3, 2025
7 checks passed
@mshroyer
Copy link
Contributor Author

mshroyer commented Nov 3, 2025

Thanks for reviewing and merging! I've rebased #35 on top of main, and it's ready for review at your convenience.

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