

def test_dict_or_list_of_ints():
    ints = UnionType((DictType, ListType), field=IntType)
    result = ints.convert(['1', '2', '3', '4'])
    assert (result == [1, 2, 3, 4])
    assert (ints.to_primitive(result) == [1, 2, 3, 4])
    result = ints.convert(dict(a=1, b=2, c=3, d=4))
    assert (ints == dict(a=1, b=2, c=3, d=4))
    assert ([type(item) for item in result.values()] == [int, int, int, int])
    assert (ints.to_primitive(result) == dict(a=1, b=2, c=3, d=4))

dataset/ETHPy150Open schematics/schematics/tests/test_union_type.py test_dict_or_list_of_ints/VarMisuse@104/123 `result`->`ints`