homepage

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.

classification
Title: add assertions to implement the intent in ''.format_map test
Type: Stage: resolved
Components: Tests Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.smith Nosy List: akira, eric.araujo, eric.smith, python-dev, rhettinger
Priority: normal Keywords: patch

Created on 2011年11月22日 00:42 by akira, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
correct-assertions-in-test_format_map.patch akira, 2011年11月22日 00:47 additional assertions with ValueError review
Messages (5)
msg148096 - (view) Author: Akira Li (akira) * Date: 2011年11月22日 00:42
It seems that some assertions in Lib/test/test_unicode.py:UnicodeTest.test_format_map do not implement their intent e.g.,
 self.assertRaises(TypeError, '{'.format_map)
 self.assertRaises(TypeError, '}'.format_map)
 self.assertRaises(TypeError, 'a{'.format_map)
 self.assertRaises(TypeError, 'a}'.format_map)
 self.assertRaises(TypeError, '{a'.format_map)
 self.assertRaises(TypeError, '}a'.format_map)
The intent might be to test:
 >>> '{'.format_map({})
 Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 ValueError: Single '{' encountered in format string
But it actually tests:
 >>> '{'.format_map()
 Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 TypeError: format_map() takes exactly one argument (0 given)
Provided correct-assertions-in-test_format_map.patch contains additional assertions e.g.,
 self.assertRaises(ValueError, '{'.format_map, {})
Old assertions might be useful so they're left untouched.
msg148113 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2011年11月22日 12:41
I don't think the existing tests have any value. I might leave one of them, but I think I'll just use your new tests instead.
akira: I'd like to add your name to the Misc/ACKS file, if it's not already there. What's your full name?
Thanks for the bug report and patch.
msg148130 - (view) Author: Akira Li (akira) * Date: 2011年11月22日 17:28
TypeError tests can check that an implementation raises a correct exception type i.e., it doesn't raise ValueError prematurely on invalid format_string without checking that there is mapping argument.
METH_O does it for CPython. I'm not sure how other implementations might behave.
eric: I'd read http://docs.python.org/devguide/patch.html#preparation but I thought 4 lines are not worth it to change Misc/ACKS. Full pseudonym: Akira Li
msg148395 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011年11月26日 12:54
When someone puts thought into a report or patch, they deserve to be in Misc/ACKS. Just noticing one typo doesn’t qualify, but pretty much anything above does. :)
msg155500 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012年03月12日 22:29
New changeset 995cddd15313 by Eric V. Smith in branch '3.2':
str.format_map tests don't do what they say: fix to actually implement the intent of the test. Closes #13450.
http://hg.python.org/cpython/rev/995cddd15313
New changeset 0df295d590a8 by Eric V. Smith in branch 'default':
str.format_map tests don't do what they say: fix to actually implement the intent of the test. Closes #13450. Patch by Akira Li.
http://hg.python.org/cpython/rev/0df295d590a8 
History
Date User Action Args
2022年04月11日 14:57:24adminsetgithub: 57659
2012年03月12日 22:29:19python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg155500

resolution: fixed
stage: resolved
2011年11月26日 12:54:18eric.araujosetnosy: + eric.araujo

messages: + msg148395
versions: - Python 3.4
2011年11月22日 17:28:50akirasetmessages: + msg148130
2011年11月22日 12:41:18eric.smithsetmessages: + msg148113
2011年11月22日 01:00:35eric.smithsetassignee: eric.smith
2011年11月22日 00:47:47akirasetfiles: - correct-assertions-in-test_format_map.patch
2011年11月22日 00:47:29akirasetfiles: + correct-assertions-in-test_format_map.patch
2011年11月22日 00:45:26akirasettitle: fix ''.format_map test -> add assertions to implement the intent in ''.format_map test
2011年11月22日 00:43:32pitrousetnosy: + rhettinger, eric.smith
2011年11月22日 00:42:35akiracreate

AltStyle によって変換されたページ (->オリジナル) /