Пример #1
0
def test_ord():
    assert match("a <b>", "") is None
    assert match("a <b>", "a") is None
    assert match("a <b>", "a", as_json=True) is None
    assert match("a <b>!", "") is None
    assert match("a <b>!", "text?") is None
    assert (match("a <b>!..<c>", "a oh!..hello!") == {
        "b": "oh",
        "c": "hello!"
    } == json.loads(match("a <b>!..<c>", "a oh!..hello!", as_json=True)))
Пример #2
0
def test_spec():
    assert match("hello", "hello") is not None
    assert match("hello", "") is None
Пример #3
0
def test_some():
    assert match("<1> <s> <1>", " road ") is None
    assert match("<1> <s> <1>", "the road to hel") == {"s": "road"}
Пример #4
0
def test_complic():
    assert match("If <conditional>, then <consequence>",
                 "If I listen to music, then I'm fine") == {
                     "conditional": "I listen to music",
                     "consequence": "I'm fine"
                 }
Пример #5
0
def test_ignore():
    assert match("<!>hello<!>", "hello") is not None
    assert match("<!>hello<!>", "test") is None
    assert match("<!> <s> <!>", "The road to hel") == {"s": "road"}
    assert match("<!> <s> <!>", " road ") == {"s": "road"}