From f59d97df85049a8b300b9e4f8e43d5b00a7f7078 Mon Sep 17 00:00:00 2001 From: HuangYan Date: Sat, 5 Oct 2019 18:10:03 +0800 Subject: [PATCH] reformat code --- tests/document/test_instance.py | 34 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/tests/document/test_instance.py b/tests/document/test_instance.py index 5999f24b41..a0059f6f54 100644 --- a/tests/document/test_instance.py +++ b/tests/document/test_instance.py @@ -314,7 +314,6 @@ class Person(Document): self.assertEqual(p._data, {'age': 18, 'id': None, 'name': u'Jack', 'lunar_age': 20}) self.assertEqual(p.to_mongo(), bson.SON([('name', u'Jack'), ('gregorian_age', 18), ('age', 20)])) - Person(name="Jack", age="18", lunar_age="20").save() Person(name="Fred", age="28", lunar_age="30").save() @@ -376,7 +375,6 @@ class User(Document): meta = {"allow_inheritance": True} with self.assertRaises(ValueError) as e: - class EmailUser(User): email = StringField(primary_key=True) @@ -775,8 +773,8 @@ class Doc(Document): d = ( Doc(embedded_field=[Embedded(string="Hi")]) - .to_mongo(use_db_field=False) - .to_dict() + .to_mongo(use_db_field=False) + .to_dict() ) self.assertEqual(d["embedded_field"], [{"string": "Hi"}]) @@ -1640,7 +1638,7 @@ class User(self.Person): self.assertEqual(person.active, False) def test__get_changed_fields_same_ids_reference_field_does_not_enters_infinite_loop_embedded_doc( - self + self ): # Refers to Issue #1685 class EmbeddedChildModel(EmbeddedDocument): @@ -1654,7 +1652,7 @@ class ParentModel(Document): self.assertEqual(changed_fields, []) def test__get_changed_fields_same_ids_reference_field_does_not_enters_infinite_loop_different_doc( - self + self ): # Refers to Issue #1685 class User(Document): @@ -2133,7 +2131,6 @@ def test_duplicate_db_fields_raise_invalid_document_error(self): declare the same db_field. """ with self.assertRaises(InvalidDocumentError): - class Foo(Document): name = StringField() name2 = StringField(db_field="name") @@ -2419,7 +2416,6 @@ class Foo(Document): def test_invalid_reverse_delete_rule_raise_errors(self): with self.assertRaises(InvalidDocumentError): - class Blog(Document): content = StringField() authors = MapField( @@ -2430,7 +2426,6 @@ class Blog(Document): ) with self.assertRaises(InvalidDocumentError): - class Parents(EmbeddedDocument): father = ReferenceField("Person", reverse_delete_rule=DENY) mother = ReferenceField("Person", reverse_delete_rule=DENY) @@ -2668,7 +2663,6 @@ def test_override_method_with_field(self): the "validate" method. """ with self.assertRaises(InvalidDocumentError): - class Blog(Document): validate = DictField() @@ -2932,8 +2926,8 @@ def __str__(self): [ str(b) for b in Book.objects.filter( - Q(extra__a=bob) | Q(author=bob) | Q(extra__b=bob) - ) + Q(extra__a=bob) | Q(author=bob) | Q(extra__b=bob) + ) ] ), "1,2,3,4", @@ -2945,10 +2939,10 @@ def __str__(self): [ str(b) for b in Book.objects.filter( - Q(extra__a__all=[karl, susan]) - | Q(author__all=[karl, susan]) - | Q(extra__b__all=[karl.to_dbref(), susan.to_dbref()]) - ) + Q(extra__a__all=[karl, susan]) + | Q(author__all=[karl, susan]) + | Q(extra__b__all=[karl.to_dbref(), susan.to_dbref()]) + ) ] ), "1", @@ -2960,13 +2954,13 @@ def __str__(self): [ str(b) for b in Book.objects.filter( - __raw__={ - "$where": """ + __raw__={ + "$where": """ function(){ return this.name == '1' || this.name == '2';}""" - } - ) + } + ) ] ), "1,2",