From 5498fbad343d8662b202e183227941a992440768 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Tue, 10 Oct 2017 17:55:01 +0200 Subject: [PATCH] unify outcome exceptions --- _pytest/outcomes.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/_pytest/outcomes.py b/_pytest/outcomes.py index 19135f87462..83b1fb99710 100644 --- a/_pytest/outcomes.py +++ b/_pytest/outcomes.py @@ -8,7 +8,10 @@ import attr -@attr.s(frozen=True) +# str = true ensures repr uses str +exc = attr.s(frozen=True) + +@exc class OutcomeException(BaseException): """ OutcomeException and its subclass instances indicate and contain info about test and collection outcomes. @@ -31,7 +34,7 @@ def __repr__(self): TEST_OUTCOME = (OutcomeException, Exception) -@attr.s(frozen=True) +@exc class Skipped(OutcomeException): # XXX hackish: on 3k we fake to live in the builtins # in order to have Skipped exception printing shorter/nicer @@ -49,11 +52,13 @@ class Failed(OutcomeException): __module__ = 'builtins' -@attr.s(frozen=True) +@exc class Exit(KeyboardInterrupt): """ raised for immediate program exits (no tracebacks/summaries)""" msg = attr.ib(default="unknown reason") + def __str__(self): + return self.msg # exposed helper methods