Ran Benita
e5468681b0
Use attr.s(auto_attribs=True) in more places
...
It's nicer to read without the attr.ib noise.
2021-10-04 19:24:12 +03:00
Anthony Sottile
67af623d9e
Merge pull request #8227 from encukou/defensive-get_source
...
Make code.FormattedExcinfo.get_source more defensive
2021-04-24 19:42:53 -07:00
Miro Hrončok
0a75c8e57b
Add a regression test for a more defensive code.FormattedExcinfo.get_source
2021-04-22 19:17:54 +02:00
Tadeu Manoel
b706a2c048
Fix error with --import-mode=importlib and modules containing dataclasses or pickle ( #7870 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Fixes #7856 , fixes #7859
2021-04-05 17:10:03 -03:00
sousajf1
20c59e3aa4
pytest-dev#8204 migrate some tests to tmp_path fixture ( #8209 )
...
migrating some tests from tmpdir to tmp_path fixture
2021-01-01 17:25:11 +02:00
Ran Benita
92ba96b061
code: convert from py.path to pathlib
2020-12-22 21:08:25 +02:00
Anton
8eef8c6004
tests: Migrate to pytester - incremental update ( #8145 )
2020-12-15 13:02:32 +02:00
Ran Benita
531416cc5a
code: simplify Code construction
2020-10-31 12:40:25 +02:00
Ran Benita
a1df458e85
code: use properties for derived attributes, use slots
...
Make the objects more light weight.
Remove unused properties.
2020-10-31 12:40:25 +02:00
Hugo van Kemenade
c9e5042d6d
Remove redundant Python 2.7 code
2020-10-19 10:47:35 +03:00
Anthony Sottile
33d119f71a
py36+: com2ann
2020-10-05 18:33:17 -07:00
Anthony Sottile
66bd44c13a
py36+: pyupgrade: py36+
2020-10-03 12:46:54 -07:00
Anthony Sottile
a238d1f37d
py36+: remove TYPE_CHECKING from _pytest.compat
...
automated with:
```bash
git grep -l 'from .* import TYPE_CHECKING' |
xargs reorder-python-imports \
--application-directories .:src \
--remove-import 'from _pytest.compat import TYPE_CHECKING' \
--add-import 'from typing import TYPE_CHECKING'
```
2020-10-02 15:03:24 -07:00
Anthony Sottile
96a17b1683
Fix INTERNALERROR when accessing locals / globals with faulty `exec`
2020-09-11 18:13:48 -07:00
Bruno Oliveira
9f672c85c5
Fix handle of exceptions in ReprEntry with tb=line
...
Fix #7707
2020-09-03 07:44:45 -03:00
Ran Benita
b8471aa527
testing: fix some docstring issues
...
In preparation for enforcing some docstring lints.
2020-08-03 10:10:43 +03:00
Lewis Cowles
71ab6236a1
Clearer guidance on pytest.raise(match=...) failure ( #7499 )
2020-07-15 22:26:47 +03:00
Ran Benita
a2f021b6f3
Remove no longer needed `noqa: F821` uses
...
Not needed since pyflakes 2.2.0.
2020-07-10 13:08:56 +03:00
Ran Benita
11efe057ea
testing: skip some unreachable code in coverage
2020-07-04 12:12:52 +03:00
Ran Benita
ef39115001
code/source: remove compiling functions
...
A lot of complex code that isn't used anymore outside of tests after
the previous commit.
2020-07-01 20:20:12 +03:00
Ran Benita
4655b79985
config: improve typing
2020-06-22 16:39:14 +03:00
Ran Benita
54ad048be7
Enable check_untyped_defs mypy option for testing/ too
2020-06-05 11:34:20 +03:00
Ran Benita
59a12e9ab3
Replace bare `except`s with `except BaseException`
...
Mostly I wanted to remove uses of `noqa`.
In Python 3 the two are the same.
2020-05-12 09:29:47 +03:00
Ran Benita
66ee755649
terminalwriter: remove TerminalWriter's stringio argument
...
Had a mark indicating it should be removed, and I agree, it's better to
just use the `file` argument.
2020-04-30 16:44:02 +03:00
Daniel Hahler
2be06ba67e
Improve doc/typing/message for `ExceptionInfo.match` ( #6776 )
2020-02-21 16:41:57 +01:00
Daniel Hahler
79ae86cc3f
tests: fix test_repr_traceback_with_invalid_cwd
...
This never worked as expected (since a912d3745
), and only py38-windows
triggered the mocked `os.getcwd` unintentionally, via `inspect`.
2020-01-24 12:52:12 +01:00
Daniel Hahler
03bc8aba4e
config: typing for create_terminal_writer, re-export TerminalWriter
...
This also imports `TerminalWriter` explicitly via `_pytest._io`,
allowing for easier extending / replacing it.
2020-01-23 14:09:37 +01:00
Daniel Hahler
32b62f770f
Merge pull request #6509 from blueyed/typing-minor
...
typing: minor improvements
2020-01-19 11:33:41 +01:00
Daniel Hahler
5c445b05e7
typing: py.io.TerminalWriter for tw arguments
2020-01-19 11:21:16 +01:00
Daniel Hahler
61f985f3c7
tests: test_excinfo: remove unused pytest_version_info
...
This might fail unnecessarily with a (wrong) determined version of e.g.
"4.7.dev307+ge98176cf5" (no patch version).
Ref: https://github.com/pytest-dev/pytest/pull/6506
2020-01-19 08:11:13 +01:00
Ran Benita
eaa34a9df0
Add type annotations to _pytest._code.code
2019-11-16 22:29:57 +02:00
Ran Benita
307add025b
Simplify a FormattedExcinfo test
...
The previous test was better in that it used fakes to test all of the
real code paths. The problem with that is that it makes it impossible to
simplify the code with `isinstance` checks. So let's just simulate the
issue directly with a monkeypatch.
2019-11-16 17:22:09 +02:00
Ran Benita
5bfe793fd5
Remove unneeded getrawcode() calls from tests
2019-11-16 17:22:08 +02:00
Daniel Hahler
19b2f4bb8a
tests: use ids ( #6145 )
2019-11-07 14:43:46 +01:00
Daniel Hahler
dd6cf7c172
test_exc_chain_repr_without_traceback: use ids
2019-11-07 12:25:46 +01:00
Daniel Hahler
eb7a4e32ad
saferepr: handle BaseExceptions
...
This causes INTERNALERRORs with pytest-django, which uses
`pytest.fail` (derived from `BaseException`) to prevent DB access, when
pytest then tries to e.g. display the `repr()` for a Django `QuerySet`
etc.
Ref: https://github.com/pytest-dev/pytest-django/pull/776
2019-11-06 22:08:10 +01:00
Daniel Hahler
741f0fedd1
typing around Node.location, reportinfo, repr_excinfo etc
2019-11-05 16:22:58 +01:00
Daniel Hahler
2a2fe7d3db
Improve ExceptionInfo.__repr__
2019-10-09 19:27:46 +02:00
Bruno Oliveira
47c2091ecd
Use new no-match functions to replace previous idiom
2019-10-06 18:05:24 -03:00
Daniel Hahler
f832ac3316
Handle --fulltrace with pytest.raises
...
This changes `_repr_failure_py` to use `tbfilter=False` always.
2019-09-14 01:41:43 +02:00
Bruno Oliveira
7a69365486
Move TWMock class to a fixture
...
Using a relative import like before was not very nice
2019-08-26 11:32:57 -03:00
Daniel Hahler
b5b710b3ae
Merge master into features
...
Several conflicts, mostly due to 2c402f4bd
.
Conflicts:
.pre-commit-config.yaml
src/_pytest/outcomes.py
src/_pytest/python_api.py
tox.ini
2019-08-02 16:52:51 +02:00
Semen Zhydenko
942fd91995
shouldnt -> shouldn't
2019-08-01 15:09:14 +02:00
Ran Benita
11f1f79222
Allow creating ExceptionInfo from existing exc_info for better typing
...
This way the ExceptionInfo generic parameter can be inferred from the
passed-in exc_info. See for example the replaced cast().
2019-07-14 14:28:24 +03:00
Ran Benita
89dfde9535
Add rudimentary mypy type checking
...
Add a very lax mypy configuration, add it to tox -e linting, and
fix/ignore the few errors that come up. The idea is to get it running
before diving in too much.
This enables:
- Progressively adding type annotations and enabling more strict
options, which will improve the codebase (IMO).
- Annotating the public API in-line, and eventually exposing it to
library users who use type checkers (with a py.typed file).
Though, none of this is done yet.
Refs https://github.com/pytest-dev/pytest/issues/3342 .
2019-07-09 12:12:07 -07:00
Ran Benita
c1167ac552
Add rudimentary mypy type checking
...
Add a very lax mypy configuration, add it to tox -e linting, and
fix/ignore the few errors that come up. The idea is to get it running
before diving in too much.
This enables:
- Progressively adding type annotations and enabling more strict
options, which will improve the codebase (IMO).
- Annotating the public API in-line, and eventually exposing it to
library users who use type checkers (with a py.typed file).
Though, none of this is done yet.
Refs https://github.com/pytest-dev/pytest/issues/3342 .
2019-07-09 10:49:17 +03:00
Bruno Oliveira
65c2a81924
Remove ExceptionInfo.__str__, falling back to __repr__
...
Fix #5412
2019-06-06 12:20:32 -03:00
Anthony Sottile
a91fe1fedd
pre-commit run pyupgrade --all-files
2019-06-03 12:08:02 -03:00
Anthony Sottile
3f1ec520fc
pre-commit run reorder-python-imports --all-files
2019-06-03 12:08:01 -03:00
Anthony Sottile
5034399d7a
pre-commit run fix-encoding-pragma --all-files
2019-06-03 12:08:01 -03:00