From 127bd8407c4c5a7441b1019ebdd1bdbcffd0bae3 Mon Sep 17 00:00:00 2001 From: Ilya Skriblovsky Date: Wed, 13 May 2015 12:06:53 +0300 Subject: [PATCH 1/2] OrderedDict replaced by custom dict subclass for the sake of py26 --- tests/test_queries.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_queries.py b/tests/test_queries.py index a3180c11..33932485 100644 --- a/tests/test_queries.py +++ b/tests/test_queries.py @@ -18,7 +18,6 @@ from twisted.trial import unittest import txmongo from txmongo.protocol import MongoClientProtocol -from collections import OrderedDict mongo_host = "localhost" mongo_port = 27017 @@ -213,8 +212,10 @@ def test_AsClass(self): doc = yield self.coll.find_one({}) self.assertIs(type(doc), dict) - doc = yield self.coll.find_one({}, as_class=OrderedDict) - self.assertIs(type(doc), OrderedDict) + class CustomDict(dict): pass + + doc = yield self.coll.find_one({}, as_class=CustomDict) + self.assertIs(type(doc), CustomDict) @defer.inlineCallbacks def tearDown(self): From b142fa1091e19cbfd4b57bede633a57386b2f83d Mon Sep 17 00:00:00 2001 From: Ilya Skriblovsky Date: Wed, 13 May 2015 14:33:50 +0300 Subject: [PATCH 2/2] assert*() methods introduced in py27 replaced with assertTrue() --- tests/test_aggregate.py | 4 ++-- tests/test_collection.py | 2 +- tests/test_queries.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_aggregate.py b/tests/test_aggregate.py index 25cc0026..70799673 100644 --- a/tests/test_aggregate.py +++ b/tests/test_aggregate.py @@ -50,8 +50,8 @@ def test_Aggregate(self): res = yield self.coll.aggregate([{"$match": {"oh": "hai"}}], full_response=True) - self.assertIn("ok", res) - self.assertIn("result", res) + self.assertTrue("ok" in res) + self.assertTrue("result" in res) self.assertEqual(len(res["result"]), 2) @defer.inlineCallbacks diff --git a/tests/test_collection.py b/tests/test_collection.py index 522e3545..1de504d0 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -86,7 +86,7 @@ def make_col(base, name): self.assertEqual(self.db.test.test, self.db.test("test")) options = yield self.db.test.options() - self.assertIsInstance(options, dict) + self.assertTrue(isinstance(options, dict)) yield self.db.drop_collection("test") collection_names = yield self.db.collection_names() diff --git a/tests/test_queries.py b/tests/test_queries.py index 33932485..b5ea730d 100644 --- a/tests/test_queries.py +++ b/tests/test_queries.py @@ -210,12 +210,12 @@ def test_AsClass(self): yield self.coll.insert({'x': 42}) doc = yield self.coll.find_one({}) - self.assertIs(type(doc), dict) + self.assertTrue(type(doc) is dict) class CustomDict(dict): pass doc = yield self.coll.find_one({}, as_class=CustomDict) - self.assertIs(type(doc), CustomDict) + self.assertTrue(type(doc) is CustomDict) @defer.inlineCallbacks def tearDown(self):