Beispiel #1
0
def test_xget_glob_keys_all():
    # type: () -> None
    "Should get keys of dict"
    obj = {'foo': 1, 'bar': 2}
    resultset = dig.xget(obj, '*')
    textual = str(resultset)
    assert textual == '[foo=1:int, bar=2:int]'
Beispiel #2
0
def test_xget_glob_keys_some():
    # type: () -> None
    "Should get keys of dict"
    assert str(dig.xget({
        'foo': 1,
        'bar': 2,
        'fx': 2
    }, 'f*')) == '[foo=1:int, fx=2:int]'
Beispiel #3
0
def test_xget_glob_attrs_some():
    # type: () -> None
    "Should get keys of object"
    assert str(dig.xget(E(foo=1, bar=2), 'f*')) == '[foo=1:int]'
Beispiel #4
0
def test_xget_glob_attrs_all():
    # type: () -> None
    "Should get keys of dict"
    assert str(dig.xget(E(foo=1, bar=2), '*')) == '[bar=2:int, foo=1:int]'
Beispiel #5
0
def test_xget_glob_members_some(itr):
    # type: () -> None
    "Should get keys of a sequence/collection"
    
    assert str(dig.xget(itr, 'f*')) == "['foo', 'fx']"
Beispiel #6
0
def test_xget_fn():
    # type: () -> None
    "Should get from function (?)"
    assert dig.xget(lambda x: x + 1, 1) == 2
Beispiel #7
0
def test_xget_object():
    # type: () -> None
    "Should obj"
    assert dig.xget(E(foo='bar'), 'foo') == 'bar'
Beispiel #8
0
def test_xget_indexed_dict():
    # type: () -> None
    "Does test_xget_indexed"
    assert dig.xget({'foo': 'bar'}, 'foo') == 'bar'
Beispiel #9
0
def test_xget_indexed_iter():
    # type: () -> None
    "Does test_xget_indexed"
    assert dig.xget((1, 2, 3), 1) == 2
Beispiel #10
0
def test_xget_prim(param: Any) -> None:
    "Does test_xget_prim"
    result = dig.xget(param, 1)
    assert result == param or all(map(math.isnan, (param, result)))