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 1
1
import operator
2
+ from datetime import timedelta
2
3
3
4
from django .core .exceptions import FieldDoesNotExist , ValidationError
4
5
from django .db import models
@@ -74,7 +75,9 @@ def test_pre_save(self):
74
75
obj = Holder .objects .create (data = Data ())
75
76
auto_now = truncate_ms (obj .data .auto_now )
76
77
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 ))
78
81
# save() updates auto_now but not auto_now_add.
79
82
obj .save ()
80
83
self .assertEqual (truncate_ms (obj .data .auto_now_add ), auto_now_add )
You can’t perform that action at this time.
0 commit comments