Skip to content
Snippets Groups Projects
Commit 44a70581 authored by lukas leufen's avatar lukas leufen
Browse files

name attribute in time tracking

parent 015c3f87
No related branches found
No related tags found
2 merge requests!59Develop,!52implemented bootstraps
Pipeline #30491 passed
......@@ -49,9 +49,10 @@ class TimeTracking(object):
method. Duration can always be shown by printing the time tracking object or calling get_current_duration.
"""
def __init__(self, start=True):
def __init__(self, start=True, name="undefined job"):
self.start = None
self.end = None
self._name = name
if start:
self._start()
......@@ -93,7 +94,7 @@ class TimeTracking(object):
def __exit__(self, exc_type, exc_val, exc_tb):
self.stop()
logging.info(f"undefined job finished after {self}")
logging.info(f"{self._name} finished after {self}")
def prepare_host(create_new=True, sampling="daily"):
......
......@@ -117,6 +117,14 @@ class TestTimeTracking:
expression = PyTestRegex(r"undefined job finished after \d+:\d+:\d+ \(hh:mm:ss\)")
assert caplog.record_tuples[-1] == ('root', 20, expression)
def test_name_enter_exit(self, caplog):
caplog.set_level(logging.INFO)
with TimeTracking(name="my job") as t:
assert t.start is not None
assert t.end is None
expression = PyTestRegex(r"my job finished after \d+:\d+:\d+ \(hh:mm:ss\)")
assert caplog.record_tuples[-1] == ('root', 20, expression)
class TestPrepareHost:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment