コード例 #1
0
def test_disable():
    @tc.typecheck
    def foo(x: int):
        pass
    tc.disable() # disable-only switch, no further proxying is performed
    @tc.typecheck
    def bar(x: int):
        pass
    foo(1)
    with expected(InputParameterError("foo() has got an incompatible value for x: 1")):
        foo("1")
    bar(1)
    bar("1")
コード例 #2
0
def test_disable():
    @tc.typecheck
    def foo(x: int):
        pass

    tc.disable()  # disable-only switch, no further proxying is performed
    try:
        @tc.typecheck
        def bar(x: int):
            pass

        foo(1)
        with expected(tc.InputParameterError("foo() has got an incompatible value for x: 1")):
            foo("1")
        bar(1)
        bar("1")
    finally:
        tc.enable()  # make sure typecheck continues to work!
コード例 #3
0
def test_disable():
    @tc.typecheck
    def foo(x: int):
        pass

    tc.disable()  # disable-only switch, no further proxying is performed

    @tc.typecheck
    def bar(x: int):
        pass

    foo(1)
    with expected(
            InputParameterError(
                "foo() has got an incompatible value for x: 1")):
        foo("1")
    bar(1)
    bar("1")
コード例 #4
0
def test_disable():
    @tc.typecheck
    def foo(x: int):
        pass

    tc.disable()  # disable-only switch, no further proxying is performed
    try:

        @tc.typecheck
        def bar(x: int):
            pass

        foo(1)
        with expected(
                tc.InputParameterError(
                    "foo() has got an incompatible value for x: 1")):
            foo("1")
        bar(1)
        bar("1")
    finally:
        tc.enable()  # make sure typecheck continues to work!
コード例 #5
0
                                  "value for return_value_error: <class 'int'>")):
    @tc.typecheck_with_exceptions(return_value_error = int)
    def foo():
        pass

print("ok")

############################################################################

print("disable: ", end="")

@typecheck
def foo(x: int):
    pass

tc.disable() # disable-only switch, no further proxying is performed

@typecheck
def bar(x: int):
    pass

foo(1)
with expected(InputParameterError("foo() has got an incompatible value for x: 1")):
    foo("1")

bar(1)
bar("1")

print("ok")

############################################################################