示例#1
0
def test_types_row_specs_eq2():
    data = OrderedDict()
    data["a"] = 1
    data["b"] = 2
    data["c"] = 3

    d = types.Row(**data)
    g = types.Row(1, 2, 3, fields_=["a", "b", "c"])
    assert d == g
示例#2
0
def test_types_row_specs_getattr():
    data = OrderedDict()
    data["a"] = 1
    data["b"] = 2
    data["c"] = 3

    d = types.Row(**data)
    assert getattr(d, "foo", None) is None
示例#3
0
def test_types_row_specs_asdict_attr():
    data = OrderedDict()
    data["a"] = 1
    data["b"] = 2
    data["c"] = 3

    d = types.Row(**data)
    assert d.b == 2
示例#4
0
def test_types_row_specs_asdict_index():
    data = OrderedDict()
    data["a"] = 1
    data["b"] = 2
    data["c"] = 3

    d = types.Row(**data)
    assert d[2] == 3
示例#5
0
def test_types_row_specs_dir():
    d = types.Row(b"1", b"2", fields_=["a", "b"])
    assert "args" not in dir(d) and "a" in dir(d)
示例#6
0
def test_types_row_specs_len():
    d = types.Row(b"1", b"2", fields_=["a", "b"])
    assert len(d) == 2
示例#7
0
def test_types_row_specs_eq2_bad():
    from uuid import uuid4

    d = uuid4()
    g = types.Row(1, 2, 3, fields_=["a", "b", "c"])
    assert d != g
示例#8
0
def test_types_row_specs_item():
    d = types.Row(1, 2, 3, fields_=["a", "b", "c"])
    assert d[2] == 3
示例#9
0
def test_types_row_specs_iter():
    d = types.Row(1, 2, 3, fields_=["a", "b", "c"])
    cnt = 0
    for _ele in d:
        cnt += 1
    assert cnt == 3
示例#10
0
def test_types_row_specs_dict():
    d = types.Row(1, 2, 3, fields_=["a", "b", "c"])
    assert dict(d.asdict_()) == {"a": 1, "b": 2, "c": 3}