Finalize python2/3 codebase compatibility and get rid of 2to3

This commit is contained in:
Bastien Gérard
2019-06-14 23:30:01 +02:00
parent 4d6ddb070e
commit 2ca905b6e5
11 changed files with 31 additions and 38 deletions

View File

@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from builtins import str
import pytest
from mongoengine import (
@@ -75,7 +77,7 @@ class TestEmbeddedDocumentField(MongoDBTestCase):
# Test non exiting attribute
with pytest.raises(InvalidQueryError) as exc_info:
Person.objects(settings__notexist="bar").first()
assert unicode(exc_info.value) == u'Cannot resolve field "notexist"'
assert str(exc_info.value) == u'Cannot resolve field "notexist"'
with pytest.raises(LookUpError):
Person.objects.only("settings.notexist")
@@ -111,7 +113,7 @@ class TestEmbeddedDocumentField(MongoDBTestCase):
# Test non exiting attribute
with pytest.raises(InvalidQueryError) as exc_info:
assert Person.objects(settings__notexist="bar").first().id == p.id
assert unicode(exc_info.value) == u'Cannot resolve field "notexist"'
assert str(exc_info.value) == u'Cannot resolve field "notexist"'
# Test existing attribute
assert Person.objects(settings__base_foo="basefoo").first().id == p.id
@@ -319,7 +321,7 @@ class TestGenericEmbeddedDocumentField(MongoDBTestCase):
# Test non exiting attribute
with pytest.raises(InvalidQueryError) as exc_info:
Person.objects(settings__notexist="bar").first()
assert unicode(exc_info.value) == u'Cannot resolve field "notexist"'
assert str(exc_info.value) == u'Cannot resolve field "notexist"'
with pytest.raises(LookUpError):
Person.objects.only("settings.notexist")
@@ -347,7 +349,7 @@ class TestGenericEmbeddedDocumentField(MongoDBTestCase):
# Test non exiting attribute
with pytest.raises(InvalidQueryError) as exc_info:
assert Person.objects(settings__notexist="bar").first().id == p.id
assert unicode(exc_info.value) == u'Cannot resolve field "notexist"'
assert str(exc_info.value) == u'Cannot resolve field "notexist"'
# Test existing attribute
assert Person.objects(settings__base_foo="basefoo").first().id == p.id