Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/model_fields_/test_embedded_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import operator
from datetime import timedelta

from django.core.exceptions import FieldDoesNotExist, ValidationError
from django.db import models
Expand Down Expand Up @@ -74,7 +75,9 @@ def test_pre_save(self):
obj = Holder.objects.create(data=Data())
auto_now = truncate_ms(obj.data.auto_now)
auto_now_add = truncate_ms(obj.data.auto_now_add)
self.assertEqual(auto_now, auto_now_add)
# auto_now and auto_now_add may differ by a millisecond since they
# aren't generated simultaneously.
self.assertAlmostEqual(auto_now, auto_now_add, delta=timedelta(microseconds=1000))
# save() updates auto_now but not auto_now_add.
obj.save()
self.assertEqual(truncate_ms(obj.data.auto_now_add), auto_now_add)
Expand Down Expand Up @@ -253,7 +256,8 @@ class MyModel(models.Model):


class SubqueryExistsTests(TestCase):
def setUpTestData(self):
@classmethod
def setUpTestData(cls):
address1 = Address(city="New York", state="NY", zip_code=10001)
address2 = Address(city="Boston", state="MA", zip_code=20002)
author1 = Author(name="Alice", age=30, address=address1)
Expand Down