def test_reinvoke_new_default_change_shortcut(): class ReinvokableWithShortcut(MyReinvokable): @classmethod @class_shortcut def shortcut(cls, call_target=None, **kwargs): kwargs['shortcut_was_here'] = True return call_target(**kwargs) assert reinvoke_new_defaults( ReinvokableWithShortcut(), dict( call_target__attribute='shortcut', foo='bar', )).kwargs == dict(foo='bar', shortcut_was_here=True)
def test_set_class_on_actions_container(): t = Table() style_data = Namespace(actions__attrs__class={'object-tools': True}, ) reinvoke_new_defaults(t, style_data)
def test_reinvokable_new_defaults_recurse(): x = MyReinvokable(foo=MyReinvokable(bar=17)) x = reinvoke_new_defaults(x, Namespace(foo__bar=42, foo__baz=43)) assert isinstance(x.kwargs.foo, MyReinvokable) assert x.kwargs.foo.kwargs == dict(bar=17, baz=43)