Beispiel #1
0
def test_walk_nok_string_dict():
    seq = {"a": "b"}
    message = r"0"
    with pytest.raises(KeyError, match=message):
        mc.walk(seq)
Beispiel #2
0
def test_walk_ok_empty_string():
    empty = ''
    assert mc.walk(empty) is None
Beispiel #3
0
def test_walk_ok_iterator_list():
    the_same = iter([1, 2, 3])
    seq = [the_same, the_same, the_same]
    assert mc.walk(seq) == the_same
Beispiel #4
0
def test_walk_ok_int_dict():
    seq = {0: "a", 1: "b"}
    assert mc.walk(seq) in seq.values()
Beispiel #5
0
def test_walk_nok_wrong_type_generator_expression():
    message = r"object of type 'generator' has no len\(\)"
    with pytest.raises(TypeError, match=message):
        mc.walk(n for n in range(1234))
Beispiel #6
0
def test_walk_ok_function_list():
    the_same = print
    seq = [the_same, the_same, the_same]
    assert mc.walk(seq) == the_same
Beispiel #7
0
def test_walk_ok_string():
    string = "abc"
    step = mc.walk(string)
    assert len(step) == 1
    assert step in string
Beispiel #8
0
def test_walk_nok_wrong_type_float():
    bad = 3.1415
    message = r"object of type 'float' has no len\(\)"
    with pytest.raises(TypeError, match=message):
        mc.walk(bad)
Beispiel #9
0
def test_walk_ok_empty_dict():
    seq = dict()
    assert mc.walk(seq) is None
Beispiel #10
0
def test_walk_ok_empty_tuple():
    seq = tuple()
    assert mc.walk(seq) is None
Beispiel #11
0
def test_walk_ok_empty_set():
    seq = {}
    assert mc.walk(seq) is None
Beispiel #12
0
def test_walk_ok_empty_list():
    seq = []
    assert mc.walk(seq) is None
Beispiel #13
0
def test_walk_nok_wrong_type_function():
    message = r"object of type 'builtin_function_or_method' has no len\(\)"
    with pytest.raises(TypeError, match=message):
        mc.walk(print)
Beispiel #14
0
def test_walk_nok_wrong_type_none():
    bad = None
    assert mc.walk(bad) is None
Beispiel #15
0
def test_walk_ok_string_list():
    the_same = "a"
    seq = [the_same, the_same, the_same]
    assert mc.walk(seq) == the_same
Beispiel #16
0
def test_walk_nok_wrong_type_int():
    bad = 42
    message = r"object of type 'int' has no len\(\)"
    with pytest.raises(TypeError, match=message):
        mc.walk(bad)
Beispiel #17
0
def test_walk_ok_range():
    a_range = range(42)
    step = mc.walk(a_range)
    assert step in a_range
    assert isinstance(step, int)
Beispiel #18
0
def main(argv=None):
    """Process ... TODO."""
    argv = sys.argv[1:] if argv is None else argv
    verbose = True if "-v" in argv or "--verbose" in argv else False
    verbose and print(f"No verbose mode implemented")
    print(walk(argv))
Beispiel #19
0
def test_walk_nok_wrong_type_complex():
    bad = complex(1, -1)
    message = r"object of type 'complex' has no len\(\)"
    with pytest.raises(TypeError, match=message):
        mc.walk(bad)