Example #1
0
def test_non_binding_trigger():
    so = object()
    fo = object()
    f = non_binding_trigger("foo", sequence=so)(fo)
    r = f()
    assert r.sequence is so
    assert r.func is fo
    assert r.regex.pattern == 'foo'
Example #2
0
def test_returns_nothing_if_regex_is_None():
    f = non_binding_trigger(None)(None)
    res = list(f().match(Metaline('foobar', None, None)))
    assert not res
Example #3
0
def test_trigger_matches_multiple_times():
    f = non_binding_trigger('foo')(None)
    res = list(f().match(Metaline('foofoo', None, None)))
    assert len(res) == 2
Example #4
0
def test_trigger_non_match_doesnt_return_list():
    f = non_binding_trigger('bar')(None)
    res = list(f().match(Metaline('foo', None, None)))
    assert not res
Example #5
0
def test_trigger_match_returns_list():
    f = non_binding_trigger('foo')(None)
    res = list(f().match(Metaline('foo', None, None)))
    assert res
Example #6
0
def test_non_binding_trigger_makes_a_new_instance_each_time():
    f = non_binding_trigger(None)(None)
    assert f() is not f()