Skip to content

Commit

Permalink
Fix bug in deprecation.py (#143)
Browse files Browse the repository at this point in the history
* Update deprecation.py

* Remove explicit self argument from _getattr_ override in deprecation.py and add tests for attribute set and get.

Co-authored-by: Mark Steadman <[email protected]>
  • Loading branch information
mark-steadman and Mark Steadman authored May 7, 2021
1 parent 77bb226 commit c43b400
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fpdf/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __getattr__(self, name):
)
return None
# pylint: disable=no-member
return super().__getattr__(self, name)
return super().__getattr__(name)

def __setattr__(self, name, value):
if name in ("FPDF_CACHE_DIR", "FPDF_CACHE_MODE"):
Expand All @@ -26,4 +26,4 @@ def __setattr__(self, name, value):
stacklevel=2,
)
return
super().__setattr__(self, name, value)
super().__setattr__(name, value)
6 changes: 6 additions & 0 deletions test/fonts/test_add_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def test_deprecation_warning_for_FPDF_CACHE_DIR():
with pytest.warns(DeprecationWarning):
fpdf.FPDF_CACHE_MODE = 1

fpdf.SOME = 1
assert fpdf.SOME == 1

import fpdf

with pytest.warns(DeprecationWarning):
Expand All @@ -50,6 +53,9 @@ def test_deprecation_warning_for_FPDF_CACHE_DIR():
with pytest.warns(DeprecationWarning):
fpdf.FPDF_CACHE_MODE = 1

fpdf.SOME = 1
assert fpdf.SOME == 1


def test_add_font_unicode_with_path_fname_ok(tmp_path):
for font_cache_dir in (True, tmp_path):
Expand Down

0 comments on commit c43b400

Please sign in to comment.