@@ -119,7 +119,7 @@ def test_custom_field():
119119 assert {'title' : 'Uryyb' } == s .to_dict ()
120120 assert s .title == 'Hello'
121121
122- s . title = ' Uryyb'
122+ s = SecretDoc . from_es ({ '_source' : { 'title' : ' Uryyb'}})
123123 assert s .title == 'Hello'
124124 assert isinstance (s .title , Secret )
125125
@@ -148,7 +148,7 @@ def test_multi_works_after_doc_has_been_saved():
148148
149149def test_multi_works_in_nested_after_doc_has_been_serialized ():
150150 # Issue #359
151- c = DocWithNested (comments = [{ ' title' : ' First!'} ])
151+ c = DocWithNested (comments = [Comment ( title = ' First!') ])
152152
153153 assert [] == c .comments [0 ].tags
154154 assert {'comments' : [{'title' : 'First!' }]} == c .to_dict ()
@@ -195,7 +195,7 @@ def test_attribute_can_be_removed():
195195 assert 'title' not in d ._d_
196196
197197def test_doc_type_can_be_correctly_pickled ():
198- d = DocWithNested (title = 'Hello World!' , comments = [{ ' title' : ' hellp'} ], meta = {'id' : 42 })
198+ d = DocWithNested (title = 'Hello World!' , comments = [Comment ( title = ' hellp') ], meta = {'id' : 42 })
199199 s = pickle .dumps (d )
200200
201201 d2 = pickle .loads (s )
@@ -271,7 +271,7 @@ def password(self, pwd):
271271 u .password
272272
273273def test_nested_can_be_assigned_to ():
274- d1 = DocWithNested (comments = [{ ' title' : ' First!'} ])
274+ d1 = DocWithNested (comments = [Comment ( title = ' First!') ])
275275 d2 = DocWithNested ()
276276
277277 d2 .comments = d1 .comments
@@ -295,7 +295,7 @@ def test_nested_defaults_to_list_and_can_be_updated():
295295
296296def test_to_dict_is_recursive_and_can_cope_with_multi_values ():
297297 md = MyDoc (name = ['a' , 'b' , 'c' ])
298- md .inner = [{ ' old_field' : ' of1'}, { ' old_field' : ' of2'} ]
298+ md .inner = [MyInner ( old_field = ' of1'), MyInner ( old_field = ' of2') ]
299299
300300 assert isinstance (md .inner [0 ], MyInner )
301301
@@ -367,8 +367,9 @@ def test_document_can_be_created_dynamically():
367367
368368def test_invalid_date_will_raise_exception ():
369369 md = MyDoc ()
370+ md .created_at = 'not-a-date'
370371 with raises (ValidationException ):
371- md .created_at = 'not-a-date'
372+ md .full_clean ()
372373
373374def test_document_inheritance ():
374375 assert issubclass (MySubDoc , MyDoc )
0 commit comments