-
Notifications
You must be signed in to change notification settings - Fork 263
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
Used qpdf in all tests to compare resulting PDFs + improved development doc #33
Conversation
b376e18
to
cd4b022
Compare
There is an issue with the tests that does not happen on my computer: they seem stuck on I'll have a look at it later on |
…nt doc + removing tox
The issue is solved, this is ready for review! :) |
tox was there to run tests on all version of python locally, is there no longer a way to do that? that makes sense to keep... |
Yeah, we can keep it for sure if you are used to it! I removed it because I neither use it myself nor in the GitHub Actions pipeline: on my computer I handle virtualenvs myself with Moreover, to me it can be a bit demotivating for newcomer contributors to require to run tests with I'm going to add a commit to this PR to restore the |
yeah I get what youre coming from, like its a dependency, and i use a virtualenv too, but its also super annoying in case python introduces breaking changes or new features in 3.8 or 3.9 that some one wants to add in here and only finds out when the Github Action fails. |
OK, I understand your point. Honestly, I do not see much benefit if having it in |
this test is hanging for me locally |
How did you run the tests? With tox? Do you have any idea where exactly it hangs? |
figuring it out. ran it with tox, without qpdf it hangs with python setup.py test as well, inside my virtualenvironment. also pytest only finds some tests (not all) hangs inside the |
it hangs at: test.assertSequenceEqual(
actual_qpdf_file.readlines(), expected_qpdf_file.readlines()
) |
Well spotted! Could you try to replace |
For |
same effect |
Also, do you work under Linux or Windows? (to see if I can reproduce the issue on my side) |
linux |
ill try and come up with a docker command for it, but here's my debugging diff: diffdiff --git a/test/cell_multi_cell_refactor/cell.py b/test/cell_multi_cell_refactor/cell.py
index 672a09b..e1cfcca 100644
--- a/test/cell_multi_cell_refactor/cell.py
+++ b/test/cell_multi_cell_refactor/cell.py
@@ -57,5 +57,6 @@ class CRefactorTest(unittest.TestCase):
self, doc, "test_ln_positioning_and_page_breaking_for_cell.pdf"
)
+
if __name__ == "__main__":
unittest.main()
diff --git a/test/cell_multi_cell_refactor/multi_cell.py b/test/cell_multi_cell_refactor/multi_cell.py
index df2f4da..5450706 100644
--- a/test/cell_multi_cell_refactor/multi_cell.py
+++ b/test/cell_multi_cell_refactor/multi_cell.py
@@ -68,5 +68,6 @@ class MCRefactorTest(unittest.TestCase):
self, doc, "test_ln_positioning_and_page_breaking_for_multicell.pdf"
)
+
if __name__ == "__main__":
unittest.main()
diff --git a/test/utilities.py b/test/utilities.py
index ce00565..998e80c 100644
--- a/test/utilities.py
+++ b/test/utilities.py
@@ -53,9 +53,13 @@ def assert_pdf_equal(test, pdf_or_tmpl, rel_expected_pdf_filepath, delete=True):
actual_qpdf_file.name,
expected_qpdf_file.name,
)
- test.assertSequenceEqual(
- actual_qpdf_file.readlines(), expected_qpdf_file.readlines()
- )
+ print("actual_lines = actual_qpdf_file.read().splitlines()")
+ actual_lines = actual_qpdf_file.read().splitlines()
+ print("expected_lines = expected_qpdf_file.read().splitlines()")
+ expected_lines = expected_qpdf_file.read().splitlines()
+ print("test.assertSequenceEqual(")
+ test.assertSequenceEqual(actual_lines, expected_lines)
+ print("test.assertSequenceEqual( done!")
else: # Fallback to hash comparison
actual_hash = calculate_hash_of_file(actual_pdf_file.name)
expected_hash = calculate_hash_of_file(expected_pdf_filepath)
|
|
I may not be able to look at it today due to some Windows update issues, but I'll try to solve this soon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests pass on my machine but the machine im on right now only has python 3.8.5 so hopefully all the tests do actually work (not just the ones picked up by pytest) for the other python versions.
Given that the GitHub Actions pipeline was hanging before your commit, and that now it is passing for all 4 versions of Python, I think you found a fix! Congrats :) I took good note not not to use |
I think that while debugging & commiting on this branch you erased the changes I had pushed earlier on Give me a notice when you'll be done on this, and I'll make some final changes on |
one of the tests has a differing length sequence. sorry, yep - added the changes back in. |
alright im done working on this for today, not sure why the test is failing but it looks like its genuinely failing. maybe the whole tempfile approach wasnt worth it? I guess it might not have been worth it for me when i first made this test suite - dont remember why exactly i went with the way i did |
Ok, I'll take over then, no worry :) I was able to reproduce the issue with Docker |
I think the origin of the "hanging" call to |
that's, umm, hilariously bad... So i guess i incorrectly identified the point of failure then and it can be reverted to namedtmpfile? i just tried it with |
I'm on it :) |
…e.assertSequenceEqual limitation due to difflib
Looks good to me :) |
Just a notice: I created python-pillow/Pillow#5190 to investigate why the This is non blocking though, and I had witnessed this inconsistent behaviour before this PR. |
Thank you for the review & merge @alexanderankin ! |
Pros:
qpdf
is not availableCons:
Note: it could be even better to use
pdfrw
to compare PDFs,but sadly this does not support comparison so far: pmaupin/pdfrw#212