fix recent tests update with unittest2pytest
This commit is contained in:
		| @@ -544,23 +544,19 @@ class TestIndexes(unittest.TestCase): | |||||||
|             BlogPost(name=name).save() |             BlogPost(name=name).save() | ||||||
|  |  | ||||||
|         query_result = BlogPost.objects.collation(base).order_by("name") |         query_result = BlogPost.objects.collation(base).order_by("name") | ||||||
|         self.assertEqual( |         assert [x.name for x in query_result] == sorted(names, key=lambda x: x.lower()) | ||||||
|             [x.name for x in query_result], sorted(names, key=lambda x: x.lower()) |         assert 5 == query_result.count() | ||||||
|         ) |  | ||||||
|         self.assertEqual(5, query_result.count()) |  | ||||||
|  |  | ||||||
|         query_result = BlogPost.objects.collation(Collation(**base)).order_by("name") |         query_result = BlogPost.objects.collation(Collation(**base)).order_by("name") | ||||||
|         self.assertEqual( |         assert [x.name for x in query_result] == sorted(names, key=lambda x: x.lower()) | ||||||
|             [x.name for x in query_result], sorted(names, key=lambda x: x.lower()) |         assert 5 == query_result.count() | ||||||
|         ) |  | ||||||
|         self.assertEqual(5, query_result.count()) |  | ||||||
|  |  | ||||||
|         incorrect_collation = {"arndom": "wrdo"} |         incorrect_collation = {"arndom": "wrdo"} | ||||||
|         with self.assertRaises(OperationFailure): |         with pytest.raises(OperationFailure): | ||||||
|             BlogPost.objects.collation(incorrect_collation).count() |             BlogPost.objects.collation(incorrect_collation).count() | ||||||
|  |  | ||||||
|         query_result = BlogPost.objects.collation({}).order_by("name") |         query_result = BlogPost.objects.collation({}).order_by("name") | ||||||
|         self.assertEqual([x.name for x in query_result], sorted(names)) |         assert [x.name for x in query_result] == sorted(names) | ||||||
|  |  | ||||||
|     def test_unique(self): |     def test_unique(self): | ||||||
|         """Ensure that uniqueness constraints are applied to fields. |         """Ensure that uniqueness constraints are applied to fields. | ||||||
|   | |||||||
| @@ -4626,7 +4626,8 @@ class TestQueryset(unittest.TestCase): | |||||||
|         bars = Bar.objects.read_preference(ReadPreference.SECONDARY_PREFERRED) |         bars = Bar.objects.read_preference(ReadPreference.SECONDARY_PREFERRED) | ||||||
|         assert bars._read_preference == ReadPreference.SECONDARY_PREFERRED |         assert bars._read_preference == ReadPreference.SECONDARY_PREFERRED | ||||||
|         assert ( |         assert ( | ||||||
|             bars._cursor.collection.read_preference == ReadPreference.SECONDARY_PREFERRED |             bars._cursor.collection.read_preference | ||||||
|  |             == ReadPreference.SECONDARY_PREFERRED | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         # Make sure that `.read_preference(...)` does accept string values. |         # Make sure that `.read_preference(...)` does accept string values. | ||||||
| @@ -5765,13 +5766,13 @@ class TestQueryset(unittest.TestCase): | |||||||
|  |  | ||||||
|     def test_no_cursor_timeout(self): |     def test_no_cursor_timeout(self): | ||||||
|         qs = self.Person.objects() |         qs = self.Person.objects() | ||||||
|         self.assertEqual(qs._cursor_args, {})  # ensure no regression of  #2148 |         assert qs._cursor_args == {}  # ensure no regression of  #2148 | ||||||
|  |  | ||||||
|         qs = self.Person.objects().timeout(True) |         qs = self.Person.objects().timeout(True) | ||||||
|         self.assertEqual(qs._cursor_args, {}) |         assert qs._cursor_args == {} | ||||||
|  |  | ||||||
|         qs = self.Person.objects().timeout(False) |         qs = self.Person.objects().timeout(False) | ||||||
|         self.assertEqual(qs._cursor_args, {"no_cursor_timeout": True}) |         assert qs._cursor_args == {"no_cursor_timeout": True} | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|   | |||||||
| @@ -625,8 +625,8 @@ class ConnectionTest(unittest.TestCase): | |||||||
|             alias="conn1", host="mongodb://localhost/testing?w=1&journal=true" |             alias="conn1", host="mongodb://localhost/testing?w=1&journal=true" | ||||||
|         ) |         ) | ||||||
|         conn2 = connect("testing", alias="conn2", w=1, journal=True) |         conn2 = connect("testing", alias="conn2", w=1, journal=True) | ||||||
|         self.assertEqual(conn1.write_concern.document, {"w": 1, "j": True}) |         assert conn1.write_concern.document == {"w": 1, "j": True} | ||||||
|         self.assertEqual(conn2.write_concern.document, {"w": 1, "j": True}) |         assert conn2.write_concern.document == {"w": 1, "j": True} | ||||||
|  |  | ||||||
|     def test_connect_with_replicaset_via_uri(self): |     def test_connect_with_replicaset_via_uri(self): | ||||||
|         """Ensure connect() works when specifying a replicaSet via the |         """Ensure connect() works when specifying a replicaSet via the | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user