Skip to content

Commit

Permalink
reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
HuangYan committed Oct 5, 2019
1 parent 2c8c1c7 commit f59d97d
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions tests/document/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"}])

Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand Down Expand Up @@ -2668,7 +2663,6 @@ def test_override_method_with_field(self):
the "validate" method.
"""
with self.assertRaises(InvalidDocumentError):

class Blog(Document):
validate = DictField()

Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit f59d97d

Please sign in to comment.