From 6430ae97eca57f4db4bcef54436df6c2abcd21ad Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Tue, 16 Sep 2014 17:36:52 -0500 Subject: [PATCH] Last two issues related to the python 3 merge tests: fixed! - Fix the "pulling the error out of excinfo" stuff for py3 - The u"" only gets embedded in the string on py2. This commit sponsored by Jeff Gibson. Thanks, Jeff! :) --- mediagoblin/tests/test_api.py | 16 ++++++++-------- mediagoblin/tests/test_edit.py | 9 +++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/mediagoblin/tests/test_api.py b/mediagoblin/tests/test_api.py index e3a06cf8..6b0722aa 100644 --- a/mediagoblin/tests/test_api.py +++ b/mediagoblin/tests/test_api.py @@ -145,7 +145,7 @@ class TestAPI(object): headers=headers ) - assert "403 FORBIDDEN" in excinfo.value.message + assert "403 FORBIDDEN" in excinfo.value.args[0] def test_unable_to_post_feed_as_someone_else(self, test_app): """ Tests that can't post an image to someone else's feed """ @@ -168,7 +168,7 @@ class TestAPI(object): headers=headers ) - assert "403 FORBIDDEN" in excinfo.value.message + assert "403 FORBIDDEN" in excinfo.value.args[0] def test_only_able_to_update_own_image(self, test_app): """ Test's that the uploader is the only person who can update an image """ @@ -200,7 +200,7 @@ class TestAPI(object): headers=headers ) - assert "403 FORBIDDEN" in excinfo.value.message + assert "403 FORBIDDEN" in excinfo.value.args[0] def test_upload_image_with_filename(self, test_app): """ Tests that you can upload an image with filename and description """ @@ -263,7 +263,7 @@ class TestAPI(object): ) # Assert that we've got a 403 - assert "403 FORBIDDEN" in excinfo.value.message + assert "403 FORBIDDEN" in excinfo.value.args[0] def test_object_endpoint(self, test_app): """ Tests that object can be looked up at endpoint """ @@ -354,7 +354,7 @@ class TestAPI(object): headers=headers ) - assert "403 FORBIDDEN" in excinfo.value.message + assert "403 FORBIDDEN" in excinfo.value.args[0] def test_unable_to_update_someone_elses_comment(self, test_app): """ Test that you're able to update someoen elses comment. """ @@ -399,7 +399,7 @@ class TestAPI(object): headers=headers ) - assert "403 FORBIDDEN" in excinfo.value.message + assert "403 FORBIDDEN" in excinfo.value.args[0] def test_profile(self, test_app): """ Tests profile endpoint """ @@ -436,7 +436,7 @@ class TestAPI(object): with pytest.raises(AppError) as excinfo: response = test_app.get("/api/whoami") - assert "401 UNAUTHORIZED" in excinfo.value.message + assert "401 UNAUTHORIZED" in excinfo.value.args[0] def test_read_feed(self, test_app): """ Test able to read objects from the feed """ @@ -471,7 +471,7 @@ class TestAPI(object): with pytest.raises(AppError) as excinfo: self._post_image_to_feed(test_app, data) - assert "403 FORBIDDEN" in excinfo.value.message + assert "403 FORBIDDEN" in excinfo.value.args[0] def test_object_endpoint_requestable(self, test_app): """ Test that object endpoint can be requested """ diff --git a/mediagoblin/tests/test_edit.py b/mediagoblin/tests/test_edit.py index 547b382e..384929cb 100644 --- a/mediagoblin/tests/test_edit.py +++ b/mediagoblin/tests/test_edit.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import six import six.moves.urllib.parse as urlparse import pytest @@ -252,5 +253,9 @@ class TestMetaDataEdit: assert new_metadata == old_metadata context = template.TEMPLATE_TEST_CONTEXT[ 'mediagoblin/edit/metadata.html'] - assert context['form'].errors['media_metadata'][0]['identifier'][0] == \ - "'On the worst day' is not a 'date-time'" + if six.PY2: + expected = "u'On the worst day' is not a 'date-time'" + else: + expected = "'On the worst day' is not a 'date-time'" + assert context['form'].errors[ + 'media_metadata'][0]['identifier'][0] == expected -- 2.25.1