File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -103,3 +103,25 @@ def test_save_deferred_field_with_update_fields():
103
103
# Test that providing a deferred field to the update_fields
104
104
# save parameter doesn't raise a KeyError anymore.
105
105
tm .save (update_fields = ['boolean' ])
106
+
107
+ @pytest .mark .django_db
108
+ def test_deferred_field_was_not_dirty ():
109
+ TestModel .objects .create ()
110
+ tm = TestModel .objects .defer ('boolean' ).first ()
111
+ tm .boolean = False
112
+ assert tm .get_dirty_fields () == {}
113
+
114
+ @pytest .mark .django_db
115
+ def test_save_deferred_field_with_update_fields ():
116
+ """ Behavoir of Deferred fields have change in django 1.10. This tests
117
+ reflects this differents behavior.
118
+ """
119
+
120
+ TestModel .objects .create ()
121
+ tm = TestModel .objects .defer ('boolean' ).first ()
122
+ tm .save (update_fields = ['boolean' ])
123
+ tm .boolean = False
124
+ if django .VERSION < (1 , 10 ):
125
+ assert tm .get_dirty_fields () == {}
126
+ else :
127
+ assert tm .get_dirty_fields () == {'boolean' : True }
You can’t perform that action at this time.
0 commit comments