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")
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!
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")
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!
"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") ############################################################################