Exemplo n.º 1
0
def testSelfAsFirstArgumentIsIgnored():
    def foo(self, bar=None):
        pass

    args, kwargs = Backend.getArgAndCallString(foo)

    assert 'bar=None' == args
    assert 'bar=bar' == kwargs
Exemplo n.º 2
0
def testArgumentWithStringDefault():
    def foo(bar='baz'):
        pass

    args, kwargs = Backend.getArgAndCallString(foo)

    assert "bar='baz'" == args
    assert 'bar=bar' == kwargs
Exemplo n.º 3
0
def testGettingSignatureForMethodWithKeywordArgumentOnly():
    def foo(bar=None):
        pass

    args, kwargs = Backend.getArgAndCallString(foo)

    assert 'bar=None' == args
    assert 'bar=bar' == kwargs
Exemplo n.º 4
0
def testGettingSignatureForMethodWithMixedArguments():
    def foo(bar, baz=None):
        pass

    args, kwargs = Backend.getArgAndCallString(foo)

    assert 'bar, baz=None' == args
    assert 'bar=bar, baz=baz' == kwargs
Exemplo n.º 5
0
def testGettingSignatureForMethodWithOnePositionalArgument():
    def foo(bar):
        pass

    args, kwargs = Backend.getArgAndCallString(foo)

    assert 'bar' == args
    assert 'bar=bar' == kwargs
Exemplo n.º 6
0
def testGettingSignatureForMethodWithMultiplePositionalArguments():
    def foo(bar, baz):
        pass

    args, kwargs = Backend.getArgAndCallString(foo)

    assert 'bar, baz' == args
    assert 'bar=bar, baz=baz' == kwargs
Exemplo n.º 7
0
def testGettingSignatureForMethodWithoutArguments():
    def foo():
        pass

    args, kwargs = Backend.getArgAndCallString(foo)

    assert not args
    assert not kwargs
Exemplo n.º 8
0
def testMethodWithAllTypesOfArguments():
    def foo(ironman, blackWidow=True, *hulk, **deadpool):
        pass

    args, kwargs = Backend.getArgAndCallString(foo)

    assert "ironman, blackWidow=True, *hulk, **deadpool" == args
    assert 'ironman=ironman, blackWidow=blackWidow, *hulk, **deadpool' == kwargs
Exemplo n.º 9
0
def testVariableKeywordArguments():
    def foo(**bar):
        pass

    args, kwargs = Backend.getArgAndCallString(foo)

    assert "**bar" == args
    assert '**bar' == kwargs
Exemplo n.º 10
0
def testArgumentWithPositionalArgumentAndVariableArgumentCount():
    def foo(bar, *baz):
        pass

    args, kwargs = Backend.getArgAndCallString(foo)

    assert "bar, *baz" == args
    assert 'bar=bar, *baz' == kwargs
Exemplo n.º 11
0
def testArgumentWithVariableArgumentCount():
    def foo(*bar):
        pass

    args, kwargs = Backend.getArgAndCallString(foo)

    assert "*bar" == args
    assert '*bar' == kwargs