From d5e5433553a52d93654b863669593f68a6a7556e Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Thu, 4 Oct 2018 21:43:41 -0400 Subject: [PATCH] Add descriptive message for timeout --- src/_pytest/pytester.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 1b836e546..7037b41c7 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -1065,13 +1065,19 @@ class Testdir(object): cmdargs, stdout=f1, stderr=f2, close_fds=(sys.platform != "win32") ) timeout = kwargs.get("timeout") + + timeout_message = ( + "{seconds} second timeout expired running:" + " {command}".format(seconds=timeout, command=cmdargs) + ) + if timeout is None: ret = popen.wait() elif six.PY3: try: ret = popen.wait(timeout) except subprocess.TimeoutExpired: - raise self.TimeoutExpired() + raise self.TimeoutExpired(timeout_message) else: end = time.time() + timeout @@ -1082,7 +1088,7 @@ class Testdir(object): remaining = end - time.time() if remaining <= 0: - raise self.TimeoutExpired() + raise self.TimeoutExpired(timeout_message) time.sleep(remaining * 0.9) finally: