コード例 #1
0
def test_keep_non_alphanumeric():
    assert parse_boolean('He?ll?o') == 'He?ll?o'
コード例 #2
0
def test_single_word():
    assert parse_boolean('Hello') == 'Hello'
コード例 #3
0
def test_ending_and_whitespace():
    with pytest.raises(ValueError):
        parse_boolean('(nemo AND fish) AND  ')
コード例 #4
0
def test_whitespace_only():
    with pytest.raises(ValueError):
        parse_boolean('  ')
コード例 #5
0
def test_and_or():
    with pytest.raises(ValueError):
        parse_boolean('AND OR')
コード例 #6
0
def test_empty_string():
    with pytest.raises(ValueError):
        parse_boolean('')
コード例 #7
0
def test_precedence_parentheses():
    expected = ('AND', [('OR', ['Hello', 'WORLD']), '!'])
    assert parse_boolean('(Hello OR (WORLD)) AND !') == expected
コード例 #8
0
def test_no_unnecessary_nesting():
    expected = ('AND', ['Hello', 'WORLD', '!'])
    assert parse_boolean('(Hello AND (WORLD) AND !)') == expected
コード例 #9
0
def test_operator_precedence():
    expected = ('OR', ['Hello', ('AND', ['WORLD', '!'])])
    assert parse_boolean('Hello OR (WORLD) AND !') == expected
コード例 #10
0
def test_single_parentheses():
    assert parse_boolean('(HELLO)') == '(HELLO)'