Ticket #22705: 22705-test.diff

File 22705-test.diff, 1.2 KB (added by Tim Graham, 10 years ago)
  • tests/bulk_create/models.py

    diff --git a/tests/bulk_create/models.py b/tests/bulk_create/models.py
    index fcc4b41..3084249 100644
    a b class State(models.Model):  
    2828class TwoFields(models.Model):
    2929    f1 = models.IntegerField(unique=True)
    3030    f2 = models.IntegerField(unique=True)
     31
     32
     33class NoFields(models.Model):
     34    pass
  • tests/bulk_create/tests.py

    diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py
    index 8648184..5feff72 100644
    a b from django.db import connection  
    66from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
    77from django.test import override_settings
    88
    9 from .models import Country, Restaurant, Pizzeria, State, TwoFields
     9from .models import Country, Restaurant, Pizzeria, State, TwoFields, NoFields
    1010
    1111
    1212class BulkCreateTests(TestCase):
    class BulkCreateTests(TestCase):  
    164164        TwoFields.objects.all().delete()
    165165        with self.assertNumQueries(1):
    166166            TwoFields.objects.bulk_create(objs, len(objs))
     167
     168    def test_empty_model(self):
     169        objs = [NoFields() for i in range(3)]
     170        NoFields.objects.bulk_create(objs)
Back to Top