From ba8ae427e250ff90206bbacaae4709b49ef9f95e Mon Sep 17 00:00:00 2001 From: pytry Date: Sun, 5 Oct 2014 14:49:15 +0200 Subject: [PATCH] Added test for ValueError in custom assert message with % sign (issue #604) https://bitbucket.org/hpk42/pytest/issue/604/valueerror-unsupported-format-character-in --- testing/test_assertmessage.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 testing/test_assertmessage.py diff --git a/testing/test_assertmessage.py b/testing/test_assertmessage.py new file mode 100644 index 000000000..ca67ff55a --- /dev/null +++ b/testing/test_assertmessage.py @@ -0,0 +1,18 @@ + +def test_assert_message_fail(): + ''' + Check if custom message with % sign do not raise ValueError + Later test can be parametrized with other problematic chars + ''' + + MESSAGE = 'Message with %' + + try: + assert False, MESSAGE + except ValueError, ve: + assert False, 'ValueError was raised with the following message: ' \ + + ve.message + except AssertionError, ae: + assert MESSAGE == ae.message, 'Assertion message: ' + ae.message \ + + ' is different than expected: ' + MESSAGE + \ No newline at end of file