Skip to content

Commit

Permalink
DEV: Adjust string formatting to be able to use mutmut (#1020)
Browse files Browse the repository at this point in the history
Relates to davidhalter/parso#207

Additionally, make Makefile more consistent
  • Loading branch information
MartinThoma authored Jun 23, 2022
1 parent 187224a commit 7d820f0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ testtype:
mutation-test:
mutmut run

mutmut-results:
mutation-results:
mutmut junitxml --suspicious-policy=ignore --untested-policy=ignore > mutmut-results.xml
junit2html mutmut-results.xml mutmut-results.html

Expand Down
6 changes: 5 additions & 1 deletion PyPDF2/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,11 @@ def write_to_stream(
stream.write(b"(")
for c in bytearr:
if not chr(c).isalnum() and c != b" ":
stream.write(b_(rf"\{c:0>3o}"))
# This:
# stream.write(b_(rf"\{c:0>3o}"))
# gives
# https://github.com/davidhalter/parso/issues/207
stream.write(b_("\\%03o" % c))
else:
stream.write(b_(chr(c)))
stream.write(b")")
Expand Down
1 change: 1 addition & 0 deletions mutmut-test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash -e
pytest -x
mypy PyPDF2 --show-error-codes --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports
1 change: 1 addition & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def test_encrypt(use_128bit):

reader = PdfReader(tmp_filename, password="userpwd")
new_text = reader.pages[0].extract_text()
assert reader.metadata.get("/Producer") == "PyPDF2"

assert new_text == orig_text

Expand Down

0 comments on commit 7d820f0

Please sign in to comment.