From 6539ca5eb032a1fd2d9b5650c50e356e488bdcd8 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Tue, 17 Dec 2019 14:33:06 +0100 Subject: [PATCH] Log spy actions to file when running tests --- src/Test/Spy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Test/Spy.py b/src/Test/Spy.py index 8062d063..44422550 100644 --- a/src/Test/Spy.py +++ b/src/Test/Spy.py @@ -1,3 +1,5 @@ +import logging + class Spy: def __init__(self, obj, func_name): self.obj = obj @@ -6,11 +8,12 @@ class Spy: self.calls = [] def __enter__(self, *args, **kwargs): + logging.debug("Spy started") def loggedFunc(cls, *args, **kwargs): call = dict(enumerate(args, 1)) call[0] = cls call.update(kwargs) - print("Logging", call) + logging.debug("Spy call: %s" % call) self.calls.append(call) return self.func_original(cls, *args, **kwargs) setattr(self.obj, self.__name__, loggedFunc)