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

@@ -2,6 +2,7 @@
"""pytest: unit and functional testing with Python."""
from . import collect
from _pytest import __version__
from _pytest._code import ExceptionInfo
from _pytest.assertion import register_assert_rewrite
from _pytest.cacheprovider import Cache
from _pytest.capture import CaptureFixture
@@ -79,6 +80,7 @@ __all__ = [
"console_main",
"deprecated_call",
"exit",
"ExceptionInfo",
"ExitCode",
"fail",
"File",