classification
Title: extend captured_output to simulate different stdout.encoding
Type: enhancement Stage: patch review
Components: Tests Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: adfrost, berker.peksag, eric.araujo, ezio.melotti, flox, mike_hart, rhettinger
Priority: normal Keywords: easy, patch

Created on 2010-02-22 13:09 by flox, last changed 2019-12-04 00:48 by adfrost.

Files
File name Uploaded Description Edit
issue7982.diff berker.peksag, 2014-06-23 16:36 review
Pull Requests
URL Status Linked Edit
PR 15881 open adfrost, 2019-09-10 15:57
Messages (6)
msg99730 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-02-22 13:09
For some tests (doctest, unittest, pydoc...) it would be useful to simulate different stdout encodings ("ascii", "utf-8", ...).

The context manager could accept an optional encoding argument in this case.
msg220756 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-16 20:37
Seems like a good idea but it'll go nowhere without a patch, anybody up for it?
msg221366 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014-06-23 16:36
Here's a patch to add an optional encoding parameter to captured_stdout.
msg349927 - (view) Author: Andrew Frost (adfrost) * Date: 2019-08-18 23:50
The patch Berker attached back in 2014 was never added to Python, I'd like to submit a PR for it as my first Python contribution!
msg351743 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-09-10 22:19
This seems like a reasonable idea and the PR looks good as well.

Can you provide some examples where we would have used this in the current test suite?
msg357772 - (view) Author: Andrew Frost (adfrost) * Date: 2019-12-04 00:48
in test_xmlrpc.py, it can replace this entire function
- https://github.com/python/cpython/blob/8f4ef3b019ce380022018587571b0f970e668de3/Lib/test/test_xmlrpc.py#L1344
in test_source_encoding.py, it can remove this line
- https://github.com/python/cpython/blob/8f4ef3b019ce380022018587571b0f970e668de3/Lib/test/test_source_encoding.py#L209

It could also be useful if a test file switches between encoding schemes frequently.
History
Date User Action Args
2019-12-04 00:48:48adfrostsetmessages: + msg357772
2019-09-10 22:19:04rhettingersetnosy: + rhettinger
messages: + msg351743
2019-09-10 15:57:11adfrostsetpull_requests: + pull_request15522
2019-08-18 23:50:11adfrostsetnosy: + adfrost
messages: + msg349927
2019-03-15 23:39:14BreamoreBoysetnosy: - BreamoreBoy
2014-06-23 16:36:33berker.peksagsetfiles: + issue7982.diff

nosy: + berker.peksag
messages: + msg221366

keywords: + patch
stage: needs patch -> patch review
2014-06-17 11:55:22berker.peksagsetversions: - Python 2.7
2014-06-16 20:37:15BreamoreBoysetnosy: + BreamoreBoy

messages: + msg220756
versions: + Python 2.7, Python 3.5, - Python 3.4
2013-07-25 04:10:22ezio.melottisetnosy: + ezio.melotti
2013-07-06 17:54:29serhiy.storchakasetversions: + Python 3.4, - Python 3.2
2013-07-06 13:19:09mike_hartsetnosy: + mike_hart
2010-11-28 04:02:10eric.araujosetnosy: + eric.araujo
2010-11-28 04:02:02eric.araujosetkeywords: + easy
stage: needs patch
2010-07-11 14:22:11BreamoreBoysetversions: + Python 3.2, - Python 2.7
2010-02-22 13:09:16floxcreate