[Python] "python -m doctest" ignores files with same names in different directories

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    Suppose we have two files:

    fail/stuff.py


    """
    >>> True
    False
    """

    pass/stuff.py


    """
    >>> True
    True
    """


    Then we run them both under doctest:

    python -m doctest fail/stuff.py pass/stuff.py


    As expected, we see an error from fail/stuff.py. But if we run them in the opposite order:

    python -m doctest pass/stuff.py fail/stuff.py


    Then it passes!

    Is there some fundamental reason why Python's import system is unable to cope with loading tests from both files, or is doctest simply broken?

    Continue reading...

Compartilhe esta Página