Add missing docstrings.

This commit is contained in:
Florian Bruhin 2015-03-17 06:39:02 +01:00
parent 94bc10405a
commit 2dcf323077
2 changed files with 7 additions and 0 deletions

View File

@ -156,6 +156,7 @@ class TestLogTime(unittest.TestCase):
"""Test log_time."""
def test_log_time(self):
"""Test if log_time logs properly."""
logger = logging.getLogger('qt-tests')
with self.assertLogs(logger, logging.DEBUG) as logged:
with debug.log_time(logger, action='foobar'):

View File

@ -254,6 +254,12 @@ def format_call(func, args=None, kwargs=None, full=True):
@contextlib.contextmanager
def log_time(logger, action='operation'):
"""Log the time the operation in the with-block takes.
Args:
logger: The logging.Logger to use for logging.
action: A description of what's being done.
"""
started = datetime.datetime.now()
yield
finished = datetime.datetime.now()