Erotemic / xdoctest

A rewrite of Python's builtin doctest module (with pytest plugin integration) with AST instead of REGEX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pytest doesnt show doctest stdout when given -s

Erotemic opened this issue · comments

Here is a MWE

"""
__file__ = mwe.py 
"""

def foo():
    """
    Example:
        >>> foo()
        >>> print('stuff')
    """
    print('bar')

if __name__ == '__main__':
    r"""
    CommandLine:
        python mwe.py foo
        pytest mwe.py::foo:0 -s
    """
    import xdoctest
    xdoctest.doctest_module(__file__)

Using the xdoctest runner stdout displays as normal
python mwe.py foo

Start doctest_module('mwe.py')
gathering tests
running 1 test(s)
============
* BEGIN DOCTEST : mwe.py::foo:0
bar
stuff
* SUCCESS: mwe.py::foo:0

But using the pytest mechanism nothing is shown
pytest mwe.py::foo:0 -s

============================= test session starts ==============================
platform linux -- Python 3.5.2, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /home/joncrall/code/xdoctest, inifile: pytest.ini
plugins: xdist-1.20.0, timeout-1.2.0, threadleak-0.2.0, interactive-0.1.1, forked-0.2, cov-2.5.1, xdoctest-0.0.12
collected 1 item                                                                

mwe.py .

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

Possible reason: verbose may not be passed down to the xdoctest DocTest.run method from the pytest plugin.