Skip to content
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

Fix multi.dot Graphviz regression test #211

Merged
merged 1 commit into from
Aug 27, 2020

Conversation

peternowee
Copy link
Member

Commit d6602ad of 2018-12-01 fixed the regression test broken by commit 2d55978 of 2016-07-01. This revealed that test/graphs/multi.dot was failing.

multi.dot was introduced in commit 2b3f088 of 2010-11-07 together with many of the other tests still here today. It has not been touched since. It is a DOT-file containing two digraphs. The regression test compares the JPEG images rendered from the DOT-file by pydot with those rendered by Graphviz's dot directly.

Commit 66734d2 of 2016-07-01 is the actual cause of the failure. It changed one of the render methods of the regression test, _render_with_pydot, from calculating a single hash for all the JPEG images to calculating separate hashes for each JPEG image and then concatenating those hashes in one long string. The other render method, _render_with_graphviz, still calculates a single hash over all data. For DOT-files that generate only one image the end result is the same, but because multi.dot has two graphs, it produces two images and this leads to comparing a string of two hashes with one single hash.

I do not think the change in generating the hash was intentional, for the following reasons:

  • Commit 66734d2 states that its purpose was to adapt the test to an API change in pydot. It does not mention a deliberate choice to change the testing method.
  • There was no effort to change _render_with_graphviz to also produce multiple hashes.
  • Except for easier debugging in case of a failing test with multiple images (AFAICT, only multi.dot), I do not see much added benefit in checking a concatenation of the hashes of all images vs. checking one hash of all images together: In both cases the test will fail if one or more images is rendered differently.
  • Given that there were many commits authored that same hour, including commit 2d55978 which broke the regression tests, I suspect the author did not run the tests for each individual commit, but only at the end of that batch, and was therefore also not alerted of this change by the test suite.

Assuming that the change was not intended, this commit will now revert _render_with_pydot to the old behavior of calculating a single hash from all JPEG image data.

Tested with Debian 9.9, Graphviz 2.38.0-17, Python 2.7.13-2 and 3.5.3-1.

Fixes #204.

Commit d6602ad of 2018-12-01 fixed the regression test broken by commit
2d55978 of 2016-07-01. This revealed that `test/graphs/multi.dot` was
failing.

`multi.dot` was introduced in commit 2b3f088 of 2010-11-07 together
with many of the other tests still here today. It has not been touched
since. It is a DOT-file containing two digraphs. The regression test
compares the JPEG images rendered from the DOT-file by pydot with those
rendered by Graphviz's dot directly.

Commit 66734d2 of 2016-07-01 is the actual cause of the failure. It
changed one of the render methods of the regression test,
`_render_with_pydot`, from calculating a single hash for all the JPEG
images to calculating separate hashes for each JPEG image and then
concatenating those hashes in one long string. The other render method,
`_render_with_graphviz`, still calculates a single hash over all data.
For DOT-files that generate only one image the end result is the same,
but because `multi.dot` has two graphs, it produces two images and this
leads to comparing a string of two hashes with one single hash.

I do not think the change in generating the hash was intentional, for
the following reasons:
- Commit 66734d2 states that its purpose was to adapt the test to an
  API change in pydot. It does not mention a deliberate choice to
  change the testing method.
- There was no effort to change `_render_with_graphviz` to also produce
  multiple hashes.
- Except for easier debugging in case of a failing test with multiple
  images (AFAICT, only `multi.dot`), I do not see much added benefit in
  checking a concatenation of the hashes of all images vs. checking one
  hash of all images together: In both cases the test will fail if one
  or more images is rendered differently.
- Given that there were many commits authored that same hour, including
  commit 2d55978 which broke the regression tests, I suspect the author
  did not run the tests for each individual commit, but only at the end
  of that batch, and was therefore also not alerted of this change by
  the test suite.

Assuming that the change was not intended, this commit will now revert
`_render_with_pydot` to the old behavior of calculating a single hash
from all JPEG image data.

Tested with Debian 9.9, Graphviz 2.38.0-17, Python 2.7.13-2 and 3.5.3-1.

Fixes pydot#204.
@peternowee
Copy link
Member Author

Not sure why tests are failing in AppVeyor. All tests pass successful with this PR in my setup. Some more details:

chardet    3.0.4  
pip        19.1.1 
pyparsing  2.4.0  
setuptools 41.0.1 
wheel      0.33.4

@peternowee
Copy link
Member Author

peternowee commented Aug 9, 2019

As I describe in issue #213, I think the test failures in AppVeyor can be ignored. They seem to be caused by some nondeterministic behavior that not only affects the pydot tests, but also Graphviz dot when called directly. See issue #213 for details.

This PR (#211) is still necessary to fix the multi.dot test.

@sandrotosi
Copy link

This indeed fixes the unittest failure, please merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pydot/1.4.1: FAIL: test_graphviz_regression_tests (__main__.TestGraphAPI)
2 participants