Skip to content

Display exit code with InvocationErrors #290

@pytoxbot

Description

@pytoxbot

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 #192.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions