improve failure message

pull/229/head
Min RK 2018-02-09 15:59:13 +01:00
rodzic f86fa39fc3
commit e10c3eafb7
1 zmienionych plików z 11 dodań i 1 usunięć

Wyświetl plik

@ -9,6 +9,7 @@ success.
"""
import os
import pipes
import shlex
import pytest
@ -36,13 +37,22 @@ def make_test_func(args):
class Repo2DockerTest(pytest.Function):
"""A pytest.Item for running repo2docker"""
def __init__(self, name, parent, args):
self.args = args
self.save_cwd = os.getcwd()
f = parent.obj = make_test_func(args)
super().__init__(name, parent, callobj=f)
self.save_cwd = os.getcwd()
def reportinfo(self):
return self.parent.fspath, None, ""
def repr_failure(self, excinfo):
err = excinfo.value
if isinstance(err, SystemExit):
cmd = "jupyter-repo2docker %s" % ' '.join(map(pipes.quote, self.args))
return "%s | exited with status=%s" % (cmd, err.code)
else:
return super().repr_failure(excinfo)
def teardown(self):
super().teardown()
os.chdir(self.save_cwd)