Skip to content

Commit d974f25

Browse files
committed
fix tests for python 3.8
1 parent d89e226 commit d974f25

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

numpydoc/tests/test_validate.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import sys
23
import warnings
34
from inspect import getsourcelines
45

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

1579+
# inspect.getsourcelines does not return class decorators for Python 3.8. This was
1580+
# fixed starting with 3.9: https://github.com/python/cpython/issues/60060
15781581
@pytest.mark.parametrize(
15791582
["decorated_obj", "def_line"],
15801583
[
15811584
[
15821585
"numpydoc.tests.test_validate.DecoratorClass",
1583-
getsourcelines(DecoratorClass)[-1] + 2,
1586+
getsourcelines(DecoratorClass)[-1]
1587+
+ (2 if sys.version_info.minor > 8 else 0),
15841588
],
15851589
[
15861590
"numpydoc.tests.test_validate.DecoratorClass.test_no_decorator",

0 commit comments

Comments
 (0)