Ejemplo n.º 1
0
    def preprocesses_given_bindings_and_adds_them(subject, bindings, mocker):
        processed = [bind('a'), bind('b')]
        mocker.patch.object(Keymap, '_preprocess', return_value=processed)

        subject.extend(*bindings)

        Keymap._preprocess.assert_called_with(tuple(bindings))
        assert list(iter(subject)) == processed
Ejemplo n.º 2
0
    def injects_common_context_to_bindings(binding1):
        bindings = [binding1, bind('x')]
        contexts = [context('abc').equal(42), context('def').any().equal(55)]

        result = Keymap(common_context=contexts)._preprocess(bindings)

        assert result[0].context == binding1.context + contexts
        assert result[1].context == contexts
Ejemplo n.º 3
0
 def flattens_nested_keymaps(subject, bindings):
     nested = [Keymap(bind('x'), Keymap(bind('y'))), bind('z')]
     assert subject._preprocess(nested) == bindings
Ejemplo n.º 4
0
 def flattens_nested_tuples(subject, bindings):
     nested = (bind('x'), (bind('y'), (bind('z'),)))
     assert subject._preprocess(nested) == bindings
Ejemplo n.º 5
0
 def flattens_nested_lists(subject, bindings):
     nested = [bind('x'), [bind('y'), [bind('z')]]]
     assert subject._preprocess(nested) == bindings
Ejemplo n.º 6
0
def binding1():
    return (bind('x').to('fire')
            .when('foo').any().true()
            .also('bar').true()
            .also('baz').all().false())
Ejemplo n.º 7
0
def bindings():
    return [bind('x'), bind('y'), bind('z')]