Zac Hatfield-Dodds
3a060b77e8
Revert change to traceback repr ( #7535 )
...
* Revert change to traceback repr
* Add test and changelog entry
* Restore *exact* prev output
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-07-24 13:30:38 +02: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
f5c69f3eb2
code/source: inline getsource()
...
The recursive way in which Source and getsource interact is a bit
confusing, just inline it.
2020-07-01 20:20:13 +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
4a27d7d973
code/source: remove unused method Source.putaround()
2020-07-01 20:20:11 +03:00
Ran Benita
a7303b52db
code/source: remove unused method Source.isparseable()
2020-07-01 20:20:11 +03:00
Ran Benita
a127a22d13
code/source: remove support for comparing Source with str
...
Cross-type comparisons like this are a bad idea. This isn't used.
2020-07-01 20:20:10 +03:00
Ran Benita
4108174777
code/source: remove Source(deindent: bool) parameter
...
Not used, except in tests.
2020-07-01 20:20:07 +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
Bruno Oliveira
55099e57c3
Add requested comment as per review
2020-05-19 19:20:41 -03:00
Daniel Hahler
b98a182aa1
(no) coverage
2020-05-19 19:20:41 -03:00
Daniel Hahler
61180eec93
Test behavior of Source with regard to decorators
...
Unlinke `inspect.getsource` it does not unwrap functions.
2020-05-19 19:20:41 -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
Anthony Sottile
dad328bc8a
Fix tests for python3.9
2020-05-07 05:26:55 -07:00
Ran Benita
bafc9bd58b
testing: merge code/test_terminal_writer.py into io/test_terminalwriter.py
2020-04-30 16:44:03 +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
20f6331afd
Fix TerminalRepr instances to be hashable ( #6988 )
...
pytest-xdist assumes `ExceptionChainRepr` is hashable.
Fixes https://github.com/pytest-dev/pytest/issues/6925 .
Fixes https://github.com/pytest-dev/pytest-xdist/issues/515 .
2020-04-03 00:56:53 +02:00
Daniel Hahler
2be06ba67e
Improve doc/typing/message for `ExceptionInfo.match` ( #6776 )
2020-02-21 16:41:57 +01:00
Bruno Oliveira
4209ad6fca
Use code highlighting if pygments is installed ( #6658 )
...
* Use code highlighting if pygments is installed
* Use colorama constants instead of bare ascii codes
Could not find the exact equivalent of 'hl-reset' code using colorama
constants though.
* Refactor ASCII color handling into a fixture
* Revert back to using explicit color codes
* In Python 3.5 skip rest of tests that require ordered markup in colored output
2020-02-12 08:32:37 -03:00
Daniel Hahler
61f2a26675
Code/getfslineno: keep empty co_filename
...
Previously this would be turned via `py.path.local("")` into the current
working directory.
This appears to be what `fspath = fn and py.path.local(fn) or None`
tries to avoid in `getfslineno`'s `TypeError` handling already, if
`Code` would raise it.
2020-02-03 19:09:08 +01:00
Daniel Hahler
78eddcb5b1
tests: move test_getfslineno back
...
Reverts https://github.com/pytest-dev/pytest/pull/6610 .
The tested `getfslineno` is `src/_pytest/_code/source.py` actually,
exported via `src/_pytest/_code/__init__.py`.
I've confused it with the one in `src/_pytest/compat.py` apparently.
2020-01-29 23:47:39 +01:00
Daniel Hahler
3dbc61dd80
tests: test_code: improve/clarify imports
2020-01-29 19:44:37 +01:00
Daniel Hahler
3f4b8d3aec
test_code: improve coverage
2020-01-29 02:54:12 +01:00
Daniel Hahler
a3f482ceba
tests: move test_getfslineno
...
It should be in `test_code` when testing `_pytest._code.getfslineno`,
not to be confused with `_pytest._code.source.getfslineno`.
Adds an extra assert (via https://github.com/pytest-dev/pytest/pull/6590 ).
2020-01-29 01:26:10 +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
Ran Benita
0c247be769
Add a few missing type annotations in _pytest._code
...
These are more "dirty" than the previous batch (that's why they were
left out). The trouble is that `compile` can return either a code object
or an AST depending on a flag, so we need to add an overload to make the
common case Union free. But it's still worthwhile.
2020-01-19 19:39:14 +02: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
090e260517
master: update mypy 0.740 -> 0.761
...
(cherry picked from commit 16ff9f591e
)
(cherry picked from commit 4848bbdf9a
)
2020-01-14 06:31:41 +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
14eaa05b60
Merge pull request #6143 from blueyed/test_source
...
test_source: do not instantiate Source objects during collection
2019-11-07 13:16:34 +01:00
Daniel Hahler
dd6cf7c172
test_exc_chain_repr_without_traceback: use ids
2019-11-07 12:25:46 +01:00
Daniel Hahler
cb21a8db1d
test_source: do not instantiate Source objects during collection
2019-11-07 11:44:26 +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