Skip to content

Commit

Permalink
TST: Deprecation error for arguments of PdfWriter.encrypt (#1780)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Apr 10, 2023
1 parent dc25741 commit 432229e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ exclude_lines = [
"@overload",
"deprecated",

# Don't complain about type-checking code not being hit by unit tests
"if TYPE_CHECKING",

# Don't complain about missing debug-only code:
"def __repr__",
"def __str__",
Expand Down
15 changes: 15 additions & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,22 @@ def test_encrypt(use_128bit, user_password, owner_password, pdf_file_path):
orig_text = page.extract_text()

writer.add_page(page)

with pytest.warns(UserWarning, match="pypdf only implements RC4 encryption"):
with pytest.raises(ValueError, match="owner_pwd of encrypt is deprecated."):
writer.encrypt(
owner_pwd=user_password,
owner_password=owner_password,
user_password=user_password,
use_128bit=use_128bit,
)
with pytest.raises(ValueError, match="'user_pwd' argument is deprecated"):
writer.encrypt(
owner_password=owner_password,
user_password=user_password,
user_pwd=user_password,
use_128bit=use_128bit,
)
writer.encrypt(
user_password=user_password,
owner_password=owner_password,
Expand Down

0 comments on commit 432229e

Please sign in to comment.