Beispiel #1
0
 def test(self):
     instance1 = Dummy.objects.create()
     assert type(instance1) is Dummy
     assert Model.objects.count() == 1
     TransactionManager._clear()
     instance2 = Model.objects.get(type__in=Dummy.types)
     assert id(instance1) != id(instance2)
     assert type(instance2) is Dummy
Beispiel #2
0
 def test_manager_get(self):
     with Transaction() as tran:
         self.assertEqual(Model.objects.count(), 0)
         instance = Dummy()
         self.assertEqual(Model.objects.count(), 0)
         instance.save()
     with tran:
         self.assertEqual(Model.objects.count(), 1)
         instance2 = Model.objects.get(id=instance.id)
         assert id(instance) == id(instance2)
         TransactionManager._clear()
         instance3 = Model.objects.get(id=instance.id)
         assert instance == instance3
         assert id(instance) != id(instance3)