Fix TypeError when importing pytest on Python 3.5.0 and 3.5.1

The typing module on these versions have these issues:

- `typing.Pattern` cannot appear in a Union since it is not considered a
  class.

- `@overload` is not supported in runtime. (On the other hand, mypy
  doesn't support putting it under `if False`, so we need some runtime
  hack).

Refs #5751.
This commit is contained in:
Ran Benita
2019-08-16 10:08:18 +03:00
parent 8ccc0177c8
commit 9f3bfe82cf
4 changed files with 26 additions and 12 deletions

View File

@@ -591,7 +591,7 @@ class ExceptionInfo(Generic[_E]):
)
return fmt.repr_excinfo(self)
def match(self, regexp: Union[str, Pattern]) -> bool:
def match(self, regexp: "Union[str, Pattern]") -> bool:
"""
Check whether the regular expression 'regexp' is found in the string
representation of the exception using ``re.search``. If it matches