예제 #1
0
def test_pos_and_keyword():
    result = colors('yellow', 'grey', link_color='purple')
    # not inclusive list
    print(result)
    assert 'foreground:  yellow' in result
    assert 'background:  grey' in result
    assert 'link:  purple' in result
예제 #2
0
def test_tuple_dict():
    result = colors(*sample, **sampled2)
    print(result)
    assert 'foreground: blue' in result
    assert 'background: purple' in result
    assert 'link: purple' in result
    assert 'visited: magenta' in result
예제 #3
0
def test_one():
    result = colors()
    print(result)
    assert 'foreground: red' in result
    assert 'background: blue' in result
    assert 'link: green' in result
    assert 'visited: cyan' in result
예제 #4
0
def test_pos():
    result = colors('red', 'blue', 'yellow', 'chartreuse')
    print(result)
    assert 'foreground: red' in result
    assert 'background: blue' in result
    assert 'link: yellow' in result
    assert 'visited: chartreuse' in result
예제 #5
0
def test_tuple2():
    result = colors('green', *sample)
    print(result)
    assert 'foreground: green' in result
    assert 'background: blue' in result
    assert 'link: purple' in result
    assert 'visited: cyan' in result
예제 #6
0
def test_pos_key():
    result = colors('purple', link_color="magenta")
    print(result)
    assert 'foreground: purple' in result
    assert 'background: blue' in result
    assert 'link: magenta' in result
    assert 'visited: cyan' in result
예제 #7
0
def test_call_tuple():
    t = ('red', 'blue', 'yellow', 'chartreuse')
    result = colors(*t)
    print(result)
    assert 'red' in result
    assert 'blue' in result
    assert 'chartreuse' in result
예제 #8
0
def test_deplicate():
    """
    It's an error to a keyword arguments
    """
    # I am liking pytest more and more
    with pytest.raises(TypeError):
        result = colors('yellow', fore_color='purple')
        print(result)
예제 #9
0
def test_pos_and_keyword():
    result = colors('yellow', 'gray', link_color='purple')
    # these aren't exhaustive by any means

    print(result)
    assert 'foreground: yellow' in result
    assert 'background: gray' in result
    assert 'link: purple' in result
예제 #10
0
def test_all_positional():
    result = colors('red', 'blue', 'yellow', 'chartreuse')

    # this is not everything
    print(result)
    assert 'red' in result
    assert 'blue' in result
    assert 'chartreuse' in result
예제 #11
0
def test_duplicate():
    """
    It's an error to have a keyword argument that duplicates a
    positional one
    """
    # this is the nifty pytest way to check for Exceptions
    with pytest.raises(TypeError):
        result = colors('yellow', fore_color='purple')
        print(result)
예제 #12
0
def test_manual_all_positional():
    result = colors('red', 'blue', 'yellow', 'chartreuse')

    # these aren't exhaustive by any means
    # but mostly I want to make the code runs without error
    print(result)
    assert 'red' in result
    assert 'blue' in result
    assert 'chartreuse' in result
예제 #13
0
def test_call_tuple():
    t = ('red', 'blue', 'yellow', 'chartreuse')
    result = colors(*t)

    # these aren't exhaustive by any means
    # but mostly I want to make the code runs without error
    print(result)
    assert 'red' in result
    assert 'blue' in result
    assert 'chartreuse' in result
예제 #14
0
def test_call_everything():
    t = ('red', )
    d = {'visited_color': 'cyan'}

    result = colors('blue', *t, link_color='orange', **d)
    print(result)
    assert 'foreground:  blue' in result
    assert 'background:  red' in result
    assert 'visited:  cyan' in result
    assert 'link:  orange' in result
예제 #15
0
def test_call_tuple_dict():
    t = ('red', 'blue')

    d = {'visited_color': 'cyan', 'link_color': 'green'}

    result = colors(*t, **d)

    print(result)
    assert ' foreground:  red' in result
    assert 'background:  blue' in result
    assert 'visited:  cyan' in result
    assert 'link:  green' in result
예제 #16
0
def test_duplicate2():
    """
    It's an error to have a keyword argument that duplicates a
    positional one
    """
    # this is a way to do it by hand:
    try:
        result = colors('yellow', fore_color='purple')
        print(result)
        assert False
    except TypeError as err:
        # you can also check if the error message is what you expect
        assert "multiple values for argument" in err.args[0]
예제 #17
0
def test_call_dict():
    d = {'fore_color': 'red',
         'visited_color': 'cyan',
         'link_color': 'green',
         'back_color': 'blue',
         }
    result = colors(**d)

    print(result)
    assert 'foreground: red' in result
    assert 'background: blue' in result
    assert 'visited: cyan' in result
    assert 'link: green' in result
예제 #18
0
def test_call_everything():
    """
    this one uses:
      - a positional argument
      - *tuple
      - a keyword argument
      - **dict
    """
    t = ('red', )  # note the extra comma to amke it a tuple!

    d = {'visited_color': 'cyan'}

    result = colors('blue', *t, link_color='orange', **d)

    print(result)
    assert 'foreground: blue' in result
    assert 'background: red' in result
    assert 'visited: cyan' in result
    assert 'link: orange' in result
예제 #19
0
def test_pos_key_duplicate():
    with pytest.raises(TypeError):
        result = colors('purple', fore_color="magenta")
        print(result)
예제 #20
0
def test_call_undefined_kwarg():
    # should get an error passing in non-existand keyword
    with pytest.raises(TypeError):
        result = colors(weird_color='grey')
예제 #21
0
def test_one_keyword():
    result = colors(link_color='purple')
    # these aren't exhaustive by any means
    # but mostly I want to make the code runs without error
    print(result)
    assert 'link: purple' in result
예제 #22
0
def test_call_undefined_kwarg():
    with pytest.raises(TypeError):
        result = colors(wierd_color='grey')
예제 #23
0
def test_one_keyword():
    result = colors(link_color='purple')
    # another attempt to test
    print(result)
    assert 'link:  purple' in result