New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add assertions to implement the intent in ''.format_map test #57659
Comments
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. |
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. |
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 |
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. :) |
New changeset 995cddd15313 by Eric V. Smith in branch '3.2': New changeset 0df295d590a8 by Eric V. Smith in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: