예제 #1
0
def test_compat_option():
    option = compat_option("--foo", default=1, state_key="foo")
    ctx = Mock(name="ctx")
    param = Mock(name="param")
    state = ctx.ensure_object.return_value
    state.foo = 33
    print(dir(option(ctx)))
    assert option(ctx)._callback(ctx, param, None) == 33
    assert option(ctx)._callback(ctx, param, 44) == 44
    state.foo = None
    assert option(ctx)._callback(ctx, param, 44) == 44
예제 #2
0
def test_compat_option():
    option = compat_option('--foo', default=1, state_key='foo')
    ctx = Mock(name='ctx')
    param = Mock(name='param')
    state = ctx.ensure_object.return_value
    state.foo = 33
    print(dir(option(ctx)))
    option(ctx)._callback(ctx, param, None) == 33
    option(ctx)._callback(ctx, param, 44) == 44
    state.foo = None
    option(ctx)._callback(ctx, param, 44) == 44
예제 #3
0
 def test_repr(self):
     assert repr(option('--foo', '--bar', default=1))
예제 #4
0
 def test_repr(self):
     assert repr(option("--foo", "--bar", default=1))