Issue17217
Created on 2013-02-16 23:02 by zach.ware, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (4) |
|
|
msg182248 - (view) |
Author: Zachary Ware (zach.ware) *  |
Date: 2013-02-16 23:02 |
test_format is an interesting case in the ongoing test discovery conversion. It already uses unittest.main(), but still has test_main(), and discovery seems to work fine on Linux. On Windows, however, test_format and test_non_ascii both fail with a UnicodeEncodeError. Running under regrtest, this doesn't happen because of regrtest's replace_stdout() function. Thus, running python -m test.test_format with the following patch works: diff -r 168efd87e051 Lib/test/test_format.py --- a/Lib/test/test_format.py Fri Feb 15 23:38:23 2013 +0200 +++ b/Lib/test/test_format.py Sat Feb 16 15:14:52 2013 -0600 @@ -325,9 +325,7 @@ self.assertIs("{0:5s}".format(text), text) -def test_main(): - support.run_unittest(FormatTest) - - if __name__ == "__main__": + from test.regrtest import replace_stdout + replace_stdout() unittest.main() Doing the same in a setUpModule function would work for both running the module and for a unittest discover command, but it would also cause replace_stdout() to be called twice when running under regrtest, which I don't think would be especially good. The attached patch is one possible solution that I've come up with. It moves replace_stdout from regrtest to support, and adds a "running_under_regrtest" flag to support that regrtest sets to True. test_format then checks support.running_under_regrtest in setUpModule to determine whether to run support.replace_stdout. |
|
|
msg182541 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2013-02-20 18:42 |
In order to fix test discovery on Windows the attached patch should be enough. There are two somewhat unrelated issues though: 1) moving replace_stdout to test.support (and possibly turn it into a context manager/decorator); 2) use unittest verbosity to control the output of test_format instead of test.support.verbose; Apparently there's no API to access the unittest verbosity level, so that would be a new feature request. |
|
|
msg182678 - (view) |
Author: Zachary Ware (zach.ware) *  |
Date: 2013-02-22 17:59 |
Your patch is certainly much simpler and more effective than mine; consider mine withdrawn. I didn't take the simple step of figuring out exactly where the problem was happening and was just trying to fix the issue without changing anything in the actual tests....oops :-S I'll raise other issues about moving replace_stdout and unittest verbosity soon. |
|
|
msg182716 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2013-02-23 05:58 |
New changeset 831be7dc260a by Ezio Melotti in branch '3.2': #17217: fix UnicodeEncodeErrors errors in test_format by printing ASCII only. http://hg.python.org/cpython/rev/831be7dc260a New changeset 3eb693462891 by Ezio Melotti in branch '3.3': #17217: merge with 3.2. http://hg.python.org/cpython/rev/3eb693462891 New changeset 562ba95dd4c9 by Ezio Melotti in branch 'default': #17217: merge with 3.3. http://hg.python.org/cpython/rev/562ba95dd4c9 |
|
|
History |
|
|
|
Date |
User |
Action |
Args |
2022-04-11 14:57:41 |
admin |
set |
github: 61419 |
2013-02-23 05:59:23 |
ezio.melotti |
set |
status: open -> closedassignee: ezio.melottiresolution: fixedstage: resolved |
2013-02-23 05:58:43 |
python-dev |
set |
nosy: + python-devmessages: + |
2013-02-22 17:59:53 |
zach.ware |
set |
messages: + |
2013-02-20 18:42:06 |
ezio.melotti |
set |
files: + issue17217.diffmessages: + |
2013-02-16 23:02:28 |
zach.ware |
create |
|