Skip to content

Commit

Permalink
Account for Python 3.7 in the 7.4.x branch
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Sep 7, 2023
1 parent 3dc0657 commit e7f94ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/_pytest/doctest.py
Expand Up @@ -545,7 +545,9 @@ def _from_module(self, module, object):
Here we override `_from_module` to check the underlying
function instead. https://github.com/python/cpython/issues/107995
"""
if isinstance(object, functools.cached_property):
if hasattr(functools, "functools") and isinstance(
object, functools.cached_property
):
object = object.func

Check warning on line 551 in src/_pytest/doctest.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/doctest.py#L551

Added line #L551 was not covered by tests

# Type ignored because this is a private function.
Expand Down
3 changes: 3 additions & 0 deletions testing/test_doctest.py
Expand Up @@ -482,6 +482,9 @@ def test_doctestmodule(self, pytester: Pytester):
reprec = pytester.inline_run(p, "--doctest-modules")
reprec.assertoutcome(failed=1)

@pytest.mark.skipif(
sys.version_info[:2] <= (3, 7), reason="Only Python 3.7 or less"
)
def test_doctest_cached_property(self, pytester: Pytester):
p = pytester.makepyfile(
"""
Expand Down

0 comments on commit e7f94ed

Please sign in to comment.