Skip to content

Commit

Permalink
fix assertions about test exception contents
Browse files Browse the repository at this point in the history
- Extract the original exception from the ExceptionInfo object, this changed in Pytest 5
  • Loading branch information
ThrawnCA committed Dec 12, 2024
1 parent 3990a22 commit 899204e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ckanext/validation/tests/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_resource_validation_wrong_format(self):

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

assert "Unsupported resource format" in str(e)
assert "Unsupported resource format" in str(e.value)

def test_resource_validation_no_url_or_upload(self):

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

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

assert "Resource must have a valid URL" in str(e)
assert "Resource must have a valid URL" in str(e.value)

@mock.patch("ckanext.validation.logic.action.enqueue_job")
def test_resource_validation_with_url(self, mock_enqueue_job):
Expand Down Expand Up @@ -529,8 +529,8 @@ def test_validation_fails_on_upload(self):
)

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

@pytest.mark.usefixtures("mock_uploads")
def test_validation_fails_no_validation_object_stored(self):
Expand Down Expand Up @@ -625,8 +625,8 @@ def test_validation_fails_on_upload(self):
)

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

@pytest.mark.usefixtures("mock_uploads")
def test_validation_fails_no_validation_object_stored(self):
Expand Down

0 comments on commit 899204e

Please sign in to comment.