class Meta: model = ModelTest not_null_validator = None type_map = ClassMap({ sa.Unicode: lambda column: (StringField if column.type.length else TextAreaField) })
def test_init_sorts_items_by_inheritance(items): class_map = ClassMap(items) assert list(class_map.items()) == [ (A5, 5), (A4, 4), (A3, 3), (A2, 2), (A, 1) ]
class Meta: model = ModelTest not_null_validator = None type_map = ClassMap({sa.Unicode: TextAreaField})
def test_getitem_throws_keyerror_for_unknown_key(): class_map = ClassMap({A: 3, B: 6}) with raises(KeyError): class_map['unknown']
def test_getitem_with_objects(key, value): class_map = ClassMap({A: 3, B: 6}) assert class_map[key] == value
def test_contains_with_isinstance_check(key): class_map = ClassMap({A: 3, B: 6}) assert key in class_map
def test_init_sorts_items_by_inheritance(items): class_map = ClassMap(items) assert list(class_map.items()) == [ (A5, 5), (A4, 4), (A3, 3), (A2, 2), (A, 1) ]