Skip to content

@cached_property is not checked for doctests #107995

Closed
@tjsmart

Description

@tjsmart

Checklist

  • I am confident this is a bug in CPython, not a bug in a third-party project
  • I have searched the CPython issue tracker,
    and am confident this bug has not been reported before

CPython versions tested on:

3.10, CPython main branch

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.13.0a0 (heads/main:607f18c894, Aug 15 2023, 08:58:26) [GCC 11.4.0]

A clear and concise description of the bug:

Doctests belonging to a functools.cached_property are not ran by doctest.

Here is a minimal example (saved in a file t.py):

from functools import cached_property


class Foo:
    @cached_property
    def my_cached_property(self):
        """
        >>> assert False
        """
        return 1

If I then invoke doctest with this file, I'd expect to see an assertion error. Instead, this doctest is skipped:

$ python -m doctest t.py  # no failing output due to assertion error
$ echo $?  # zero exit code
0

Note, this issue was originally reported here: pytest-dev/pytest#11237.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions