diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 445319e5..b04ae968 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -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 diff --git a/mongoengine/base/datastructures.py b/mongoengine/base/datastructures.py index a9abf6ea..f8b4cd92 100644 --- a/mongoengine/base/datastructures.py +++ b/mongoengine/base/datastructures.py @@ -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): diff --git a/tests/fields/test_sequence_field.py b/tests/fields/test_sequence_field.py index f96f6b06..8e6615a1 100644 --- a/tests/fields/test_sequence_field.py +++ b/tests/fields/test_sequence_field.py @@ -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