Skip to content

Commit 2fdf0f1

Browse files
committed
Fixing error messages of tests to work for Python 2
1 parent 829102b commit 2fdf0f1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/test_with.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,15 @@ def test_catch_cpp_exception(context_manager_cls, swallow_exceptions):
131131

132132

133133
def test_bad_context_managers():
134-
with pytest.raises(AttributeError, match="object has no attribute '__exit__'"):
134+
with pytest.raises(AttributeError, match="has no attribute '__exit__'"):
135135
m.lvalue_arg(NotAContextManager())
136136

137-
with pytest.raises(AttributeError, match="object has no attribute '__enter__'"):
137+
with pytest.raises(AttributeError, match="has no attribute '__enter__'"):
138138
m.lvalue_arg(AlsoNotAContextManager())
139139

140140
with pytest.raises(TypeError,
141-
match="__exit__\\(\\) takes 1 positional argument but 4 were given"):
141+
match="(:?__exit__\\(\\) takes 1 positional argument but 4 were given)|" +
142+
"(?:__exit__\\(\\) takes exactly 1 argument \\(4 given\\))"): # Python 2
142143
m.lvalue_arg(AContextManagerWithAWrongExitSignature())
143144

144145

0 commit comments

Comments
 (0)