@@ -108,7 +108,7 @@ def f(x=3):
108108 assert f (x = 5 )
109109 except AssertionError :
110110 e = exvalue ()
111- assert "x=5" in e . msg
111+ assert "x=5" in str ( e )
112112
113113# These tests should both fail, but should fail nicely...
114114class WeirdRepr :
@@ -121,16 +121,16 @@ def bug_test_assert_repr():
121121 assert v == 1
122122 except AssertionError :
123123 e = exvalue ()
124- assert e . msg .find ('WeirdRepr' ) != - 1
125- assert e . msg .find ('second line' ) != - 1
124+ assert str ( e ) .find ('WeirdRepr' ) != - 1
125+ assert str ( e ) .find ('second line' ) != - 1
126126 assert 0
127127
128128def test_assert_non_string ():
129129 try :
130130 assert 0 , ['list' ]
131131 except AssertionError :
132132 e = exvalue ()
133- assert e . msg .find ("list" ) != - 1
133+ assert str ( e ) .find ("list" ) != - 1
134134
135135def test_assert_implicit_multiline ():
136136 try :
@@ -139,7 +139,7 @@ def test_assert_implicit_multiline():
139139 2 , 3 ]
140140 except AssertionError :
141141 e = exvalue ()
142- assert e . msg .find ('assert [1, 2, 3] !=' ) != - 1
142+ assert str ( e ) .find ('assert [1, 2, 3] !=' ) != - 1
143143
144144
145145def test_assert_with_brokenrepr_arg ():
@@ -154,14 +154,14 @@ def test_multiple_statements_per_line():
154154 a = 1 ; assert a == 2
155155 except AssertionError :
156156 e = exvalue ()
157- assert "assert 1 == 2" in e . msg
157+ assert "assert 1 == 2" in str ( e )
158158
159159def test_power ():
160160 try :
161161 assert 2 ** 3 == 7
162162 except AssertionError :
163163 e = exvalue ()
164- assert "assert (2 ** 3) == 7" in e . msg
164+ assert "assert (2 ** 3) == 7" in str ( e )
165165
166166
167167class TestView :
@@ -285,8 +285,8 @@ def __init__(self, *args):
285285 super (SomeEx , self ).__init__ ()
286286 try :
287287 raise SomeEx ("hello" )
288- except AssertionError :
289- s = str (exvalue () )
288+ except AssertionError as e :
289+ s = str (e )
290290 assert 're-run' not in s
291291 assert 'could not determine' in s
292292
0 commit comments