File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 11import operator
2+ from datetime import timedelta
23
34from django .core .exceptions import FieldDoesNotExist , ValidationError
45from django .db import models
@@ -74,7 +75,9 @@ def test_pre_save(self):
7475 obj = Holder .objects .create (data = Data ())
7576 auto_now = truncate_ms (obj .data .auto_now )
7677 auto_now_add = truncate_ms (obj .data .auto_now_add )
77- self .assertEqual (auto_now , auto_now_add )
78+ # auto_now and auto_now_add may differ by a millisecond since they
79+ # aren't generated simultaneously.
80+ self .assertAlmostEqual (auto_now , auto_now_add , delta = timedelta (microseconds = 1000 ))
7881 # save() updates auto_now but not auto_now_add.
7982 obj .save ()
8083 self .assertEqual (truncate_ms (obj .data .auto_now_add ), auto_now_add )
You can’t perform that action at this time.
0 commit comments