[Pytest-commit] Issue #290: Display exit code with InvocationErrors (hpk42/tox)

Daniel Hahler issues-reply at bitbucket.org
Wed Nov 25 07:57:56 EST 2015


New issue 290: Display exit code with InvocationErrors
https://bitbucket.org/hpk42/tox/issues/290/display-exit-code-with-invocationerrors

Daniel Hahler:

When a command fails, you currently only get `ERROR: InvocationError:
'/usr/bin/false'`, but the exitcode itself is useful/important, e.g. with
py.test using 5 for "no tests collected".

The following patch would provide that, by using a custom `__str__` method for
InvocationError - but it does not handle the case where that might be missing (not all instances / calls to it provide it).

Maybe a custom `__init__` should be used to set the arguments as properties explicitly, and then use them?!

```
diff -r e9569646da4f tox/__init__.py
--- a/tox/__init__.py	Wed Nov 25 12:27:48 2015 +0100
+++ b/tox/__init__.py	Wed Nov 25 13:23:26 2015 +0100
@@ -17,6 +17,9 @@
         "signals that an interpreter could not be found"
     class InvocationError(Error):
         """ an error while invoking a script. """
+        def __str__(self):
+            return "%s: %s (exitcode %d)" % (self.__class__.__name__,
+                                             self.args[0], self.args[1])
     class MissingFile(Error):
         """ an error while invoking a script. """
     class MissingDirectory(Error):
```

This is related / similar to https://bitbucket.org/hpk42/tox/issues/192.





More information about the pytest-commit mailing list