fix from code review regarding py2py3 compat
This commit is contained in:
parent
82af5e4a19
commit
64c0cace85
@ -28,8 +28,8 @@ Python 2/3 compatibility
|
||||
|
||||
The codebase is written in a compatible manner for python 2 & 3 so it
|
||||
is important that this is taken into account when it comes to discrepencies
|
||||
between the 2 versions (check this https://python-future.org/compatible_idioms.html).
|
||||
Travis runs run the tests against the different versions as a safety net.
|
||||
between the two versions (see https://python-future.org/compatible_idioms.html).
|
||||
Travis runs the tests against different Python versions as a safety net.
|
||||
|
||||
|
||||
Style Guide
|
||||
|
@ -1,6 +1,7 @@
|
||||
import weakref
|
||||
|
||||
from bson import DBRef
|
||||
from future.utils import listitems
|
||||
import six
|
||||
from six import iteritems
|
||||
|
||||
@ -422,10 +423,10 @@ class StrictDict(object):
|
||||
return len(list(iteritems(self)))
|
||||
|
||||
def __eq__(self, other):
|
||||
return list(self.items()) == list(other.items())
|
||||
return listitems(self) == listitems(other)
|
||||
|
||||
def __ne__(self, other):
|
||||
return list(self.items()) != list(other.items())
|
||||
return not(self == other)
|
||||
|
||||
@classmethod
|
||||
def create(cls, allowed_keys):
|
||||
|
@ -267,12 +267,12 @@ class TestSequenceField(MongoDBTestCase):
|
||||
foo = Foo(name="Foo")
|
||||
foo.save()
|
||||
|
||||
assert not (
|
||||
"base.counter" in self.db["mongoengine.counters"].find().distinct("_id")
|
||||
assert (
|
||||
"base.counter" not in self.db["mongoengine.counters"].find().distinct("_id")
|
||||
)
|
||||
assert ("foo.counter" and "bar.counter") in self.db[
|
||||
"mongoengine.counters"
|
||||
].find().distinct("_id")
|
||||
existing_counters = self.db["mongoengine.counters"].find().distinct("_id")
|
||||
assert "foo.counter" in existing_counters
|
||||
assert "bar.counter" in existing_counters
|
||||
assert foo.counter == bar.counter
|
||||
assert foo._fields["counter"].owner_document == Foo
|
||||
assert bar._fields["counter"].owner_document == Bar
|
||||
|
Loading…
x
Reference in New Issue
Block a user