[Pytest-commit] Issue #481: Running doctests with -s fails? (hpk42/pytest)

Luke Lee issues-reply at bitbucket.org
Wed Mar 12 14:49:36 CET 2014


New issue 481: Running doctests with -s fails?
https://bitbucket.org/hpk42/pytest/issue/481/running-doctests-with-s-fails

Luke Lee:

I'm running pytest 2.5.2 with Python 2.7 and see some doctests fail unless I pass the -s flag to turn of stdout capturing.  Is this expected?

This issue is either an esoteric bug in pytest or a problem with my tests.

For example, I wrote this simple test and it passes with or without the -s flag:


```
#!python

def test_func():
    """
    >>> print 'hello'
    hello
    """
    pass
```

However, this doctest will fail if I do not use the -s flag:

    def saveRecentProjectPath(self, new_path):
        r"""
        Save given path to rolling unique recent XML file paths
        (projects or datasets)

        This recent file paths list is meant to be used for recent xml files
        users opened recently by name, not implicitly by opening a project
        file.  So, the implicit convention is to only update a new path here
        when the user explictly requests a file path with a dialog.

        >>> settings = UserSettings('.test_settings')
        >>> settings.clearRecentProjectPaths()
        >>> settings.saveRecentProjectPath('this/is/a/test')
        >>> settings.recentProjectPaths()
        ['this/is/a/test']
    """

The real world test is a bit more complicated, but it passes as-is with the -s flag.  So, it leads me to think the issue has something to do with the stdout capturing in pytest.  Also, the test passes as-is with nose and other tools regardless of log capturing.

Any ideas?




More information about the pytest-commit mailing list