Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_nested(self):
"""Test that nesting of type checker context managers works as expected."""
def foo(a: int):
pass
with warnings.catch_warnings(record=True):
warnings.simplefilter('ignore', DeprecationWarning)
parent = TypeChecker(__name__)
child = TypeChecker(__name__)
with parent, pytest.warns(TypeWarning) as record:
foo('x')
with child:
foo('x')
assert len(record) == 3
def checker(self):
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
return TypeChecker(__name__)
def checker(self):
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
return TypeChecker(__name__)
def test_nested(self):
"""Test that nesting of type checker context managers works as expected."""
def foo(a: int):
pass
with warnings.catch_warnings(record=True):
warnings.simplefilter('ignore', DeprecationWarning)
parent = TypeChecker(__name__)
child = TypeChecker(__name__)
with parent, pytest.warns(TypeWarning) as record:
foo('x')
with child:
foo('x')
assert len(record) == 3
def init_typeguard() -> None:
from typeguard import TypeChecker
global tc
tc = TypeChecker(check_mods)
tc.start()