Skip to content

Running single test function with --doctest-modules raises an error #3843

@hoefling

Description

@hoefling

Origin: question on SO

Prep for reproducing:

$ mkdir issue
$ printf 'def test_spam():\n    assert True\n' > issue/test_eggs.py
$ pytest issue/test_eggs.py::test_spam
========================================================== test session starts ==========================================================
platform darwin -- Python 3.6.4, pytest-3.7.2, py-1.5.4, pluggy-0.7.1
rootdir: /private/tmp, inifile:
collected 1 item

issue/test_eggs.py .                                                                                                              [100%]

======================================================= 1 passed in 0.01 seconds ========================================================

Adding --doctest-modules to the previous command fails the test run:

$ pytest issue/test_eggs.py::test_spam --doctest-modules
========================================================== test session starts ==========================================================
platform darwin -- Python 3.6.4, pytest-3.7.2, py-1.5.4, pluggy-0.7.1
rootdir: /private/tmp, inifile:
collecting 0 items
===================================================== no tests ran in 0.00 seconds ======================================================
ERROR: not found: /private/tmp/issue/test_eggs.py::test_spam
(no name '/private/tmp/issue/test_eggs.py::test_spam' in any of [<DoctestModule 'issue/test_eggs.py'>, <Module 'issue/test_eggs.py'>])

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: doctestsrelated to the doctests builtin plugintopic: collectionrelated to the collection phasetype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions