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! :)
This commit is contained in:
Christopher Allan Webber 2014-09-16 17:36:52 -05:00
parent 1db2bd3fe7
commit 6430ae97ec
2 changed files with 15 additions and 10 deletions

View File

@ -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 """

View File

@ -14,6 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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