Skip to content

Commit

Permalink
Handle callable staticmethods (py3.10);
Browse files Browse the repository at this point in the history
Up to python 3.10, staticmethods were not callable - so they were skipped by the condition.
Since python 3.10, staticmethods ARE callable - so adding the `isinstance(v, staticmethod)`
to the same `if` statement would consistently handle staticmethods across python
versions <=3.9 and >= 3.10.
This solves for:
```
self = <tests.test_datetimes.Tester object at 0x1073dc5e0>

    def test_class_decorator_respects_staticmethod(self):
>       assert self.helper() == datetime.date(2012, 1, 14)

tests/test_datetimes.py:453:
...
>               result = func(*args, **kwargs)
E               TypeError: Tester.helper() takes 0 positional arguments but 1 was given

freezegun/api.py:809: TypeError
```
  • Loading branch information
micromoses committed Feb 17, 2023
1 parent bfcbfb8 commit 3d5d60b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion freezegun/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ def tearDown(*args, **kwargs):
continue
seen.add(attr)

if not callable(attr_value) or inspect.isclass(attr_value):
if not callable(attr_value) or inspect.isclass(attr_value) or isinstance(attr_value, staticmethod):
continue

try:
Expand Down

0 comments on commit 3d5d60b

Please sign in to comment.