Skip to content

Commit

Permalink
improve failure message
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Feb 9, 2018
1 parent f86fa39 commit e10c3ea
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

import os
import pipes
import shlex

import pytest
Expand Down Expand Up @@ -36,13 +37,22 @@ def test():
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)
Expand Down

0 comments on commit e10c3ea

Please sign in to comment.