[issue12527] assertRaisesRegex doc'd with 'msg' arg, but it's not implemented?
Ezio Melotti ezio.melo...@gmail.com added the comment: Brian, can you still reproduce this? I tried now with Python 3.3.0a0 (default:bfbe144986d7, Oct 20 2011, 04:35:19) and I can see the message (same output posted by Benjamin). If I run the test with python3.2 (i.e. Python 3.2 (r32:88445, Mar 25 2011, 19:28:28)), I don't get the message (same output you posted), because msg is not implemented in 3.2. Your sys.version_info output suggests you are running 3.3, but maybe you had an older version of the code (i.e. still 3.3 but before 8fc801ca9ea1)? Have you updated after the pull? -- resolution: - works for me ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12527] assertRaisesRegex doc'd with 'msg' arg, but it's not implemented?
Brian Jones bkjo...@gmail.com added the comment: I've just done a fresh hg pull and new build, and I can no longer reproduce the problem. Yay! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12527] assertRaisesRegex doc'd with 'msg' arg, but it's not implemented?
Ezio Melotti ezio.melo...@gmail.com added the comment: OK, I will close the issue then. Thanks for the quick reply! -- stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12527] assertRaisesRegex doc'd with 'msg' arg, but it's not implemented?
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12527] assertRaisesRegex doc'd with 'msg' arg, but it's not implemented?
Changes by Ezio Melotti ezio.melo...@gmail.com: -- assignee: - ezio.melotti nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12527] assertRaisesRegex doc'd with 'msg' arg, but it's not implemented?
New submission from Brian Jones bkjo...@gmail.com: The documentation here: http://docs.python.org/dev/library/unittest.html#unittest.TestCase.assertRaisesRegex Indicates that, when used as a context manager, assertRaisesRegex should accept a keyword argument 'msg'. However, that doesn't appear to actually be implemented. I've just now done an hg pull, and in Lib/unittest/case.py, the source is here: def assertRaisesRegex(self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs): Asserts that the message in a raised exception matches a regex. Args: expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertRaisesRegex is used as a context manager. args: Extra args. kwargs: Extra kwargs. context = _AssertRaisesContext(expected_exception, self, callable_obj, expected_regex) return context.handle('assertRaisesRegex', callable_obj, args, kwargs) I noticed this after attempting some simple example uses of assertRaisesRegex. Perhaps I'm just missing something that will be made obvious to others by seeing them. These are just various attempts to get my msg shown somewhere in the output: #!/usr/bin/env python3.3 import unittest class TestInt(unittest.TestCase): def test_intfail(self): # this test should *not* fail, and doesn't with self.assertRaisesRegex(ValueError, 'literal'): int('XYZ') def test_intfail2(self): # should not fail, and doesn't with self.assertRaisesRegex(ValueError, 'lambda', msg='Foo!'): int('ABC') def test_intfail3(self): # should fail, and does, but no msg to be found. with self.assertRaisesRegex(ValueError, 'literal', msg='Foo!'): int(1) def test_intfail4(self): # should fail, and does, but no msg to be found. with self.assertRaisesRegex(TypeError, 'literal', msg='Foo!'): int('ABC') if __name__ == '__main__': unittest.main() -- components: Library (Lib) messages: 140084 nosy: Brian.Jones priority: normal severity: normal status: open title: assertRaisesRegex doc'd with 'msg' arg, but it's not implemented? type: behavior versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12527] assertRaisesRegex doc'd with 'msg' arg, but it's not implemented?
Benjamin Peterson benja...@python.org added the comment: You're not getting this? .FFE == ERROR: test_intfail4 (__main__.TestInt) -- Traceback (most recent call last): File x.py, line 22, in test_intfail4 int('ABC') ValueError: invalid literal for int() with base 10: 'ABC' == FAIL: test_intfail2 (__main__.TestInt) -- ValueError: invalid literal for int() with base 10: 'ABC' During handling of the above exception, another exception occurred: Traceback (most recent call last): File x.py, line 12, in test_intfail2 int('ABC') AssertionError: lambda does not match invalid literal for int() with base 10: 'ABC' : Foo! == FAIL: test_intfail3 (__main__.TestInt) -- Traceback (most recent call last): File x.py, line 17, in test_intfail3 int(1) AssertionError: ValueError not raised : Foo! -- Ran 4 tests in 0.001s FAILED (failures=2, errors=1) -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12527] assertRaisesRegex doc'd with 'msg' arg, but it's not implemented?
Brian Jones bkjo...@gmail.com added the comment: No, I'm not. I'm sorry for not including this output initially. Here's what I get (and I've added a sys.version_info line just to be double sure the right executable is being invoked at runtime): sys.version_info(major=3, minor=3, micro=0, releaselevel='alpha', serial=0) .FFE == ERROR: test_intfail4 (__main__.TestInt) -- Traceback (most recent call last): File ./test_int.py, line 21, in test_intfail4 int('ABC') ValueError: invalid literal for int() with base 10: 'ABC' == FAIL: test_intfail2 (__main__.TestInt) -- ValueError: invalid literal for int() with base 10: 'ABC' During handling of the above exception, another exception occurred: Traceback (most recent call last): File ./test_int.py, line 13, in test_intfail2 int('ABC') AssertionError: lambda does not match invalid literal for int() with base 10: 'ABC' == FAIL: test_intfail3 (__main__.TestInt) -- Traceback (most recent call last): File ./test_int.py, line 17, in test_intfail3 int(1) AssertionError: ValueError not raised -- Ran 4 tests in 0.001s FAILED (failures=2, errors=1) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12527] assertRaisesRegex doc'd with 'msg' arg, but it's not implemented?
Brian Jones bkjo...@gmail.com added the comment: If there's some reason, based on the source snippet I posted from case.py, that my msg should be making it to the output, can someone explain why/how it should get there? I don't see any reason, from looking at the source, that 'msg' should even be expected to make it to the output. Thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com