From 869c0898876237e2514dcdcc5e63af3ac8c600da Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Sun, 12 Apr 2020 09:25:54 +0200 Subject: [PATCH 1/3] Fixes #7077: Added & improved docs for repr_failure() in Node & Collector --- src/_pytest/nodes.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 45f0aa8a1..fa26eb6d4 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -364,6 +364,14 @@ class Node(metaclass=NodeMeta): def repr_failure( self, excinfo, style=None ) -> Union[str, ReprExceptionInfo, ExceptionChainRepr, FixtureLookupErrorRepr]: + """ + Return a string representation of a collection failure. + + :param excinfo: Exception information for the failure as a tuple + (type, value, traceback), see sys.exc_info(). + :param style: Style of the representation ('long', 'short', 'auto', + None). + """ return self._repr_failure_py(excinfo, style) @@ -403,7 +411,12 @@ class Collector(Node): raise NotImplementedError("abstract") def repr_failure(self, excinfo): - """ represent a collection failure. """ + """ + Return a string representation of a collection failure. + + :param excinfo: Exception information for the failure as a tuple + (type, value, traceback), see sys.exc_info(). + """ if excinfo.errisinstance(self.CollectError) and not self.config.getoption( "fulltrace", False ): From b2582b0314d3c8570af089ec5dc9b3a4a221a870 Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Sun, 12 Apr 2020 12:00:08 +0200 Subject: [PATCH 2/3] Squash: Applied review comments --- src/_pytest/nodes.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index fa26eb6d4..0b6e5ec90 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -362,15 +362,12 @@ class Node(metaclass=NodeMeta): ) def repr_failure( - self, excinfo, style=None + self, excinfo: ExceptionInfo[Union[Failed, FixtureLookupError]], style=None ) -> Union[str, ReprExceptionInfo, ExceptionChainRepr, FixtureLookupErrorRepr]: """ - Return a string representation of a collection failure. + Return a representation of a collection or test failure. - :param excinfo: Exception information for the failure as a tuple - (type, value, traceback), see sys.exc_info(). - :param style: Style of the representation ('long', 'short', 'auto', - None). + :param excinfo: Exception information for the failure. """ return self._repr_failure_py(excinfo, style) @@ -410,12 +407,13 @@ class Collector(Node): """ raise NotImplementedError("abstract") - def repr_failure(self, excinfo): + def repr_failure( + self, excinfo: ExceptionInfo[Union[Failed, FixtureLookupError]] + ) -> Union[str, ReprExceptionInfo, ExceptionChainRepr, FixtureLookupErrorRepr]: """ - Return a string representation of a collection failure. + Return a representation of a collection or test failure. - :param excinfo: Exception information for the failure as a tuple - (type, value, traceback), see sys.exc_info(). + :param excinfo: Exception information for the failure. """ if excinfo.errisinstance(self.CollectError) and not self.config.getoption( "fulltrace", False From c9386ada29042dec120370c10437c4369f820554 Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Sun, 12 Apr 2020 13:12:33 +0200 Subject: [PATCH 3/3] Squash: Resolved 2nd round of review comments --- src/_pytest/nodes.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 0b6e5ec90..6761aa79c 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -362,7 +362,7 @@ class Node(metaclass=NodeMeta): ) def repr_failure( - self, excinfo: ExceptionInfo[Union[Failed, FixtureLookupError]], style=None + self, excinfo, style=None ) -> Union[str, ReprExceptionInfo, ExceptionChainRepr, FixtureLookupErrorRepr]: """ Return a representation of a collection or test failure. @@ -407,11 +407,9 @@ class Collector(Node): """ raise NotImplementedError("abstract") - def repr_failure( - self, excinfo: ExceptionInfo[Union[Failed, FixtureLookupError]] - ) -> Union[str, ReprExceptionInfo, ExceptionChainRepr, FixtureLookupErrorRepr]: + def repr_failure(self, excinfo): """ - Return a representation of a collection or test failure. + Return a representation of a collection failure. :param excinfo: Exception information for the failure. """