code: export ExceptionInfo for typing purposes

This type is most prominent in `pytest.raises` and we should allow to
refer to it by a public name.

The type is not in a perfectly "exposable" state. In particular:

- The `traceback` property with type `Traceback` which is derived from
  the `py.code` API and exposes a bunch more types transitively. This
  stuff is *not* exported and probably won't be.

- The `getrepr` method which probably should be private.

But they're already used in the wild so no point in just hiding them
now.

The __init__ API is hidden -- the public API for this are the `from_*`
classmethods.
This commit is contained in:
Ran Benita
2021-03-13 11:10:34 +02:00
parent 96ef7d678b
commit f2d65c85f4
11 changed files with 50 additions and 24 deletions

View File

@@ -98,7 +98,7 @@ and if you need to have access to the actual exception info you may use:
f()
assert "maximum recursion" in str(excinfo.value)
``excinfo`` is an ``ExceptionInfo`` instance, which is a wrapper around
``excinfo`` is an :class:`~pytest.ExceptionInfo` instance, which is a wrapper around
the actual exception raised. The main attributes of interest are
``.type``, ``.value`` and ``.traceback``.

View File

@@ -793,7 +793,7 @@ Config
ExceptionInfo
~~~~~~~~~~~~~
.. autoclass:: _pytest._code.ExceptionInfo
.. autoclass:: pytest.ExceptionInfo()
:members: