def test_valid_operators_return_value(self): value = [ 1, 2, 3, ] f = ArrayField() for op in ArrayField._allowed_operators: self.assertEqual(value, f.get_prep_lookup(op, value))
def test_type_is_always_array(self): f = ArrayField() setattr(f, '_type', 'int') self.assertIn('[]', f.db_type(None))
def setUp(self): self.f = ArrayField()
def test_invalid_operator_raises_type_error(self): f = ArrayField() self.assertRaises(TypeError, f.get_prep_lookup, 'contains', 'str')
def test_respects_type_of_class(self): custom_type = 'int' f = ArrayField() setattr(f, '_type', custom_type) self.assertIn(custom_type, f.db_type(None))