Skip to content

Commit

Permalink
fix tests for python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
sdiebolt committed Aug 30, 2023
1 parent d89e226 commit d974f25
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion numpydoc/tests/test_validate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import sys
import warnings
from inspect import getsourcelines

Expand Down Expand Up @@ -1575,12 +1576,15 @@ def test_raises_for_invalid_attribute_name(self, invalid_name):
with pytest.raises(AttributeError, match=msg):
numpydoc.validate.Validator._load_obj(invalid_name)

# inspect.getsourcelines does not return class decorators for Python 3.8. This was
# fixed starting with 3.9: https://github.com/python/cpython/issues/60060
@pytest.mark.parametrize(
["decorated_obj", "def_line"],
[
[
"numpydoc.tests.test_validate.DecoratorClass",
getsourcelines(DecoratorClass)[-1] + 2,
getsourcelines(DecoratorClass)[-1]
+ (2 if sys.version_info.minor > 8 else 0),
],
[
"numpydoc.tests.test_validate.DecoratorClass.test_no_decorator",
Expand Down

0 comments on commit d974f25

Please sign in to comment.