Skip to content

Commit

Permalink
Add tests for pipe behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
gtback committed Feb 12, 2016
1 parent e105c45 commit c5e2e4b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/test_grammar.py
Expand Up @@ -68,6 +68,7 @@ def test_repr():
modules = _make_grammar("blah")
assert repr(modules[0]).startswith("blah")

# Examples from the documentation

def test_basic():
"""Test a single module"""
Expand Down Expand Up @@ -127,6 +128,7 @@ def test_tee():
assert not icmp.parents
assert not malware.children

# TEE tests

def test_tee_with_three_elements():
modules = _make_grammar("(a, b, c)")
Expand Down Expand Up @@ -183,8 +185,8 @@ def test_tee_on_both_sides_of_pipe():
assert a.children == b.children == [c, d]
assert c.parents == d.parents == [a, b]


# Test option parsing

def test_option_without_value():
"""Test a module with a single flag-style option"""
_test_option_parsing("a -v", ['-v'])
Expand Down Expand Up @@ -273,7 +275,22 @@ def test_nonoption_string_token_must_be_last():
"STRING token must be last element of invocation or "
"following a OPTION token")


def test_nonoption_quoted_token_must_be_last():
_check_exception("a 'foo' bar",
"QUOTED token must be last element of invocation or "
"following a OPTION token")


# TODO These should raise a better error
def test_pipe_cannot_be_first_token():
_check_exception("| a", "list index out of range", IndexError)


# TODO This should probably raise an error rather than silently ignoring the
# trailing pipe
def test_pipe_as_last_character():
modules = _make_grammar("a |")
assert len(modules) == 1
assert not modules[0].parents
assert not modules[0].children

0 comments on commit c5e2e4b

Please sign in to comment.