@@ -298,24 +298,21 @@ def rank(self):
298298 self .assertEqual (Person .objects .get (name = "Fred" ).rank , "Private" )
299299
300300 def test_db_field_conflict (self ):
301- """Ensure we load data correctly from the right db field ."""
301+ """Ensure two db field will not conflict ."""
302302
303303 class Person (Document ):
304304 name = StringField (required = True )
305305 age = IntField (required = False , db_field = "gregorian_age" )
306306 lunar_age = IntField (required = False , db_field = "age" )
307- # in 0.18.2 version, remove db_field this will run correct
308- # age = IntField(required=False)
309- # lunar_age = IntField(required=False)
310307
311308 Person .drop_collection ()
312309 p = Person (name = "Jack" , age = "18" , lunar_age = "20" )
313310
314311 self .assertEqual (p ._data , {'age' : 18 , 'id' : None , 'name' : u'Jack' , 'lunar_age' : 20 })
315312 self .assertEqual (p .to_mongo (), bson .SON ([('name' , u'Jack' ), ('gregorian_age' , 18 ), ('age' , 20 )]))
316313
317-
318314 Person (name = "Jack" , age = "18" , lunar_age = "20" ).save ()
315+
319316 Person (name = "Fred" , age = "28" , lunar_age = "30" ).save ()
320317
321318 p = Person .objects .get (name = "Jack" )
@@ -376,7 +373,6 @@ class User(Document):
376373 meta = {"allow_inheritance" : True }
377374
378375 with self .assertRaises (ValueError ) as e :
379-
380376 class EmailUser (User ):
381377 email = StringField (primary_key = True )
382378
@@ -775,8 +771,8 @@ class Doc(Document):
775771
776772 d = (
777773 Doc (embedded_field = [Embedded (string = "Hi" )])
778- .to_mongo (use_db_field = False )
779- .to_dict ()
774+ .to_mongo (use_db_field = False )
775+ .to_dict ()
780776 )
781777 self .assertEqual (d ["embedded_field" ], [{"string" : "Hi" }])
782778
@@ -1640,7 +1636,7 @@ class User(self.Person):
16401636 self .assertEqual (person .active , False )
16411637
16421638 def test__get_changed_fields_same_ids_reference_field_does_not_enters_infinite_loop_embedded_doc (
1643- self
1639+ self
16441640 ):
16451641 # Refers to Issue #1685
16461642 class EmbeddedChildModel (EmbeddedDocument ):
@@ -1654,7 +1650,7 @@ class ParentModel(Document):
16541650 self .assertEqual (changed_fields , [])
16551651
16561652 def test__get_changed_fields_same_ids_reference_field_does_not_enters_infinite_loop_different_doc (
1657- self
1653+ self
16581654 ):
16591655 # Refers to Issue #1685
16601656 class User (Document ):
@@ -2133,7 +2129,6 @@ def test_duplicate_db_fields_raise_invalid_document_error(self):
21332129 declare the same db_field.
21342130 """
21352131 with self .assertRaises (InvalidDocumentError ):
2136-
21372132 class Foo (Document ):
21382133 name = StringField ()
21392134 name2 = StringField (db_field = "name" )
@@ -2419,7 +2414,6 @@ class Foo(Document):
24192414
24202415 def test_invalid_reverse_delete_rule_raise_errors (self ):
24212416 with self .assertRaises (InvalidDocumentError ):
2422-
24232417 class Blog (Document ):
24242418 content = StringField ()
24252419 authors = MapField (
@@ -2430,7 +2424,6 @@ class Blog(Document):
24302424 )
24312425
24322426 with self .assertRaises (InvalidDocumentError ):
2433-
24342427 class Parents (EmbeddedDocument ):
24352428 father = ReferenceField ("Person" , reverse_delete_rule = DENY )
24362429 mother = ReferenceField ("Person" , reverse_delete_rule = DENY )
@@ -2668,7 +2661,6 @@ def test_override_method_with_field(self):
26682661 the "validate" method.
26692662 """
26702663 with self .assertRaises (InvalidDocumentError ):
2671-
26722664 class Blog (Document ):
26732665 validate = DictField ()
26742666
@@ -2932,8 +2924,8 @@ def __str__(self):
29322924 [
29332925 str (b )
29342926 for b in Book .objects .filter (
2935- Q (extra__a = bob ) | Q (author = bob ) | Q (extra__b = bob )
2936- )
2927+ Q (extra__a = bob ) | Q (author = bob ) | Q (extra__b = bob )
2928+ )
29372929 ]
29382930 ),
29392931 "1,2,3,4" ,
@@ -2945,10 +2937,10 @@ def __str__(self):
29452937 [
29462938 str (b )
29472939 for b in Book .objects .filter (
2948- Q (extra__a__all = [karl , susan ])
2949- | Q (author__all = [karl , susan ])
2950- | Q (extra__b__all = [karl .to_dbref (), susan .to_dbref ()])
2951- )
2940+ Q (extra__a__all = [karl , susan ])
2941+ | Q (author__all = [karl , susan ])
2942+ | Q (extra__b__all = [karl .to_dbref (), susan .to_dbref ()])
2943+ )
29522944 ]
29532945 ),
29542946 "1" ,
@@ -2960,13 +2952,13 @@ def __str__(self):
29602952 [
29612953 str (b )
29622954 for b in Book .objects .filter (
2963- __raw__ = {
2964- "$where" : """
2955+ __raw__ = {
2956+ "$where" : """
29652957 function(){
29662958 return this.name == '1' ||
29672959 this.name == '2';}"""
2968- }
2969- )
2960+ }
2961+ )
29702962 ]
29712963 ),
29722964 "1,2" ,
0 commit comments