From 899204ede20ea9143adbea8ac900398d77d93b39 Mon Sep 17 00:00:00 2001 From: antuarc Date: Thu, 12 Dec 2024 15:34:49 +1000 Subject: [PATCH] fix assertions about test exception contents - Extract the original exception from the ExceptionInfo object, this changed in Pytest 5 --- ckanext/validation/tests/test_logic.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ckanext/validation/tests/test_logic.py b/ckanext/validation/tests/test_logic.py index 3d5beebc..40f00018 100644 --- a/ckanext/validation/tests/test_logic.py +++ b/ckanext/validation/tests/test_logic.py @@ -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): @@ -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): @@ -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): @@ -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):