Skip to content

Commit 61c7e4d

Browse files
committed
fix assertions about test exception contents
- Extract the original exception from the ExceptionInfo object, this changed in Pytest 5, see pytest-dev/pytest#5579
1 parent 3990a22 commit 61c7e4d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ckanext/validation/tests/test_logic.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_resource_validation_wrong_format(self):
4747

4848
call_action("resource_validation_run", resource_id=resource["id"])
4949

50-
assert "Unsupported resource format" in str(e)
50+
assert "Unsupported resource format" in str(e.value)
5151

5252
def test_resource_validation_no_url_or_upload(self):
5353

@@ -57,7 +57,7 @@ def test_resource_validation_no_url_or_upload(self):
5757

5858
call_action("resource_validation_run", resource_id=resource["id"])
5959

60-
assert "Resource must have a valid URL" in str(e)
60+
assert "Resource must have a valid URL" in str(e.value)
6161

6262
@mock.patch("ckanext.validation.logic.action.enqueue_job")
6363
def test_resource_validation_with_url(self, mock_enqueue_job):
@@ -529,8 +529,8 @@ def test_validation_fails_on_upload(self):
529529
)
530530

531531
assert "validation" in e.value.error_dict
532-
assert "missing-cell" in str(e)
533-
assert 'Row at position "2" has a missing cell in field "d" at position "4"' in str(e)
532+
assert "missing-cell" in str(e.value)
533+
assert 'Row at position "2" has a missing cell in field "d" at position "4"' in str(e.value)
534534

535535
@pytest.mark.usefixtures("mock_uploads")
536536
def test_validation_fails_no_validation_object_stored(self):
@@ -625,8 +625,8 @@ def test_validation_fails_on_upload(self):
625625
)
626626

627627
assert "validation" in e.value.error_dict
628-
assert "missing-cell" in str(e)
629-
assert 'Row at position "2" has a missing cell in field "d" at position "4"' in str(e)
628+
assert "missing-cell" in str(e.value)
629+
assert 'Row at position "2" has a missing cell in field "d" at position "4"' in str(e.value)
630630

631631
@pytest.mark.usefixtures("mock_uploads")
632632
def test_validation_fails_no_validation_object_stored(self):

0 commit comments

Comments
 (0)