This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bskinn
Recipients brett.cannon, bskinn, takluyver, vstinner, xtreak
Date 2019-04-22.13:52:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1555941179.62.0.311102619245.issue36695@roundup.psfhosted.org>
In-reply-to
Content
Here is warn.py, a minimal no-dependency repro script:

```
import doctest

class Tester:
    r"""Provide docstring for testing.

    >>> import warnings
    >>> from contextlib import redirect_stderr
    >>> from io import StringIO
    >>> sio = StringIO()
    >>> with redirect_stderr(sio):
    ...     warnings.warn("Warning 'containing' single quotes")
    >>> sio.getvalue()
    "...UserWarning: Warning 'containing' single quotes\n..."

    """


doctest.run_docstring_examples(
    Tester(),
    {},
    optionflags=doctest.ELLIPSIS,
)
```

`python3.7 warn.py` (3.7.3) gives no output.

`python3.8 warn.py` (3.8.0a3) gives:

```
$ python3.8 warn.py
****************************************************************
File "warn.py", line ?, in NoName
Failed example:
    sio.getvalue()
Expected:
    "...UserWarning: Warning 'containing' single quotes\n..."
Got:
    '<doctest NoName[4]>:2: UserWarning: Warning \'containing\' single quotes\n  warnings.warn("Warning \'containing\' single quotes")\n'
```

The problem appears to be centered around *doctest*, as the following script DOES NOT raise AssertionError with either of 3.7 or 3.8:

```
import warnings
from contextlib import redirect_stderr
from io import StringIO

sio = StringIO()

with redirect_stderr(sio):
    warnings.warn("Warning 'containing' single quotes")

assert " 'containing' " in sio.getvalue()
```
History
Date User Action Args
2019-04-22 13:52:59bskinnsetrecipients: + bskinn, brett.cannon, vstinner, takluyver, xtreak
2019-04-22 13:52:59bskinnsetmessageid: <1555941179.62.0.311102619245.issue36695@roundup.psfhosted.org>
2019-04-22 13:52:59bskinnlinkissue36695 messages
2019-04-22 13:52:59bskinncreate