def test_null_handling(self):
        instance = NullableIntegerArrayModel(field=None)
        instance.save()
        loaded = NullableIntegerArrayModel.objects.get()
        self.assertEqual(instance.field, loaded.field)

        instance = IntegerArrayModel(field=None)
        with self.assertRaises(IntegrityError):
            instance.save()
 def test_integers_passed_as_strings(self):
     # This checks that get_prep_value is deferred properly
     instance = IntegerArrayModel(field=['1'])
     instance.save()
     loaded = IntegerArrayModel.objects.get()
     self.assertEqual(loaded.field, [1])
 def test_dumping(self):
     instance = IntegerArrayModel(field=[1, 2])
     data = serializers.serialize('json', [instance])
     self.assertEqual(json.loads(data), json.loads(self.test_data))
 def test_tuples(self):
     instance = IntegerArrayModel(field=(1,))
     instance.save()
     loaded = IntegerArrayModel.objects.get()
     self.assertSequenceEqual(instance.field, loaded.field)
 def test_integer(self):
     instance = IntegerArrayModel(field=[1, 2, 3])
     instance.save()
     loaded = IntegerArrayModel.objects.get()
     self.assertEqual(instance.field, loaded.field)