Skip to content

Commit b991a31

Browse files
committed
Fix test failures with pytest 5
str() behavior on pytest ExceptionInfo objects was changed in pytest 5.0.0: pytest-dev/pytest#5412 This caused various tests to fail, as it was assumed that str() on those objects would include exception messages. Update the tests to check the exceptions instead, rather than the ExceptionInfo wrappers.
1 parent 3b0285c commit b991a31

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

tests/client/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,4 @@ def test_get_missing(client, requests_mocker):
164164
repo_f.result()
165165

166166
# It should explain the problem
167-
assert "repo1 was not found" in str(error)
167+
assert "repo1 was not found" in str(error.value)

tests/client/test_poller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,4 @@ def test_retries_exhausted(requests_mocker):
182182
poller(descriptors)
183183

184184
# It should pass through whatever was the underlying error
185-
assert "400 Client Error" in str(exc_info)
185+
assert "400 Client Error" in str(exc_info.value)

tests/client/test_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ def test_non_matcher():
6868
with pytest.raises(TypeError) as exc_info:
6969
field_match("oops not a matcher")
7070

71-
assert "Not a matcher" in str(exc_info)
71+
assert "Not a matcher" in str(exc_info.value)

tests/criteria/test_criteria.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ def test_field_in_str_invalid():
1212
"""
1313
with pytest.raises(ValueError) as exc_info:
1414
Criteria.with_field_in("x", "someval")
15-
assert "Must be an iterable: 'someval'" in str(exc_info)
15+
assert "Must be an iterable: 'someval'" in str(exc_info.value)

tests/fake/test_fake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_get_missing_raises():
3333
with pytest.raises(PulpException) as raised:
3434
repo_f.result()
3535

36-
assert "some-repo not found" in str(raised)
36+
assert "some-repo not found" in str(raised.value)
3737

3838

3939
def test_get_wrong_type_raises():

tests/repository/test_publish.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def test_publish_fail(fast_poller, requests_mocker, client):
171171

172172
# The exception should have a reference to the task which failed
173173
assert error.value.task.id == "task1"
174-
assert "Task task1 failed" in str(error)
174+
assert "Task task1 failed" in str(error.value)
175175

176176

177177
def test_publish_broken_response(fast_poller, requests_mocker, client):

tests/util/test_lookup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_lookup_nested_absent_raise():
1717
with pytest.raises(KeyError) as error:
1818
lookup(data, "a.b.d")
1919

20-
assert "a.b.d" in str(error)
20+
assert "a.b.d" in str(error.value)
2121

2222

2323
def test_lookup_nested_absent_default():

0 commit comments

Comments
 (0)