def _trace(self, func, *args, **kwargs): # noinspection PyUnresolvedReferences from birdseye import eye traced = eye(func) traced = self.config.snoop(*args, **kwargs)(traced) @functools.wraps(func) def wrapper(*func_args, **func_kwargs): if self.config.enabled: final_func = traced else: final_func = func return final_func(*func_args, **func_kwargs) return wrapper
def _trace(self, func, *args, **kwargs): # noinspection PyUnresolvedReferences from birdseye import eye traced = eye(func) traced = self.config.snoop(*args, **kwargs)(traced) _register_cheap_reprs() # Override birdseye in case it's outdated @functools.wraps(func) def wrapper(*func_args, **func_kwargs): if self.config.enabled: final_func = traced else: final_func = func return final_func(*func_args, **func_kwargs) return wrapper
def test_nested_arguments(self): # Python 3 sees nested arguments as a syntax error, so I can't # define the function here normally # birdseye requires a source file so I can't just use exec # The file can't just live there because then the test runner imports it path = os.path.join(os.path.dirname(__file__), 'nested_arguments.py') string_to_file(""" def f((x, y), z): return x, y, z """, path) try: from tests.nested_arguments import f f = eye(f) call = get_call_stuff(get_call_ids(lambda: f((1, 2), 3))[0]).call self.assertEqual(call.arguments, '[["x", "1"], ["y", "2"], ["z", "3"]]') self.assertEqual(call.result, "(1, 2, 3)") finally: os.remove(path)
def test_future_imports(self): from tests.future_tests import with_future, without_future self.assertEqual(with_future.foo(), eye(with_future.foo)()) self.assertEqual(without_future.foo(), eye(without_future.foo)())