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
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
be2be040f9
Clean up u' prefixes and py2 bytes conversions
2019-06-04 17:50:34 -07:00
Anthony Sottile
8292644015
Allow multiple positions for the SyntaxError in pypy3.6
2019-06-03 12:08:02 -03:00
Anthony Sottile
5dcf85c17e
manual: remove dependence on six
2019-06-03 12:08:02 -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
Bruno Oliveira
4d49ba6529
Drop Python 2.7 and 3.4 support
...
* Update setup.py requires and classifiers
* Drop Python 2.7 and 3.4 from CI
* Update docs dropping 2.7 and 3.4 support
* Fix mock imports and remove tests related to pypi's mock module
* Add py27 and 34 support docs to the sidebar
* Remove usage of six from tmpdir
* Remove six.PY* code blocks
* Remove sys.version_info related code
* Cleanup compat
* Remove obsolete safe_str
* Remove obsolete __unicode__ methods
* Remove compat.PY35 and compat.PY36: not really needed anymore
* Remove unused UNICODE_TYPES
* Remove Jython specific code
* Remove some Python 2 references from docs
Related to #5275
2019-06-02 14:39:11 -03:00
Anthony Sottile
dc75b6af47
Use fix-encoding-pragma pre-commit hook
2019-05-14 15:56:31 -07:00
Bruno Oliveira
7573747cda
Normalize all source encoding declarations
2019-05-14 19:42:44 -03:00
Bruno Oliveira
465b2d998a
Further "unknown marks warning" improvements ( #5178 )
...
Further "unknown marks warning" improvements
2019-05-11 13:28:10 -03:00
Bruno Oliveira
0594dba5ce
Remove unused markers and enable --strict-markers
2019-05-09 19:36:39 -03:00
Anthony Sottile
d1a48ad68f
Use exec directly
2019-05-06 23:07:39 -07:00
Nikolay Kondratyev
bc00d0f7db
Fix handle repr error with showlocals and verbose output
2019-04-19 18:54:21 +03:00
Daniel Hahler
8011ff5bda
Add _sys_snapshot fixture and use it with more tests
2019-04-05 11:55:23 +02:00
Daniel Hahler
2d690b83bf
ExceptionInfo.from_current: assert current exception
2019-03-23 00:29:36 +01:00
Daniel Hahler
0d31e852b1
Run isort
2019-03-01 14:24:18 +01:00
Anthony Sottile
5505826db9
Fix python3.8 / pypy failures
2019-02-16 11:23:23 -08:00
Anthony Sottile
1bba0a9714
Deprecate `raises(..., 'code(as_a_string)')` / `warns(..., 'code(as_a_string)')
2018-11-29 09:34:51 -08:00
Ronny Pfannschmidt
88bf01a31e
fix #4386 - restructure construction and partial state of ExceptionInfo
2018-11-22 21:20:32 +01:00
Anthony Sottile
2368fbb63c
Apply reorder-python-imports to all files
2018-10-25 00:01:29 -07:00
Bruno Oliveira
36dc671843
New ExceptionInfo.getrepr 'chain' parameter to be able to suppress chained exceptions
2018-10-12 10:08:55 -03:00
Anthony Sottile
a86035625c
Increase recursion limit (broke xdist tests)
2018-10-08 12:57:45 -07:00
Anthony Sottile
4f631440be
Use RuntimeError for py27 + py34 compat
2018-10-08 11:47:06 -07:00
Anthony Sottile
3901569f26
Improve performance of ~3 of the slowest tests
2018-10-08 11:12:55 -07:00
Anthony Sottile
b8b9e8d41c
Remove duplicate test (tested above)
2018-10-03 10:01:06 -07:00
Anthony Sottile
f102ccc8f0
Fix source reindenting by using `textwrap.dedent` directly.
2018-10-02 16:13:35 -07:00
Bruno Oliveira
bc009a8582
Fix test to comply with pypy 6.0
2018-10-01 18:37:27 -03:00
Daniel Hahler
7537e94ddf
tests: use unittest.mock with py34+
...
Fixes https://github.com/pytest-dev/pytest/issues/3965 .
Has to work around https://github.com/tox-dev/tox/issues/706 .
No coverage for pluggymaster builds is OK though anyway.
2018-09-12 23:21:47 +02:00
Anthony Sottile
1e8e17c01e
Improve the coverage of testing/code
2018-08-26 16:13:22 -07:00
Anthony Sottile
f2e35c8c4f
Merge pull request #3859 from asottile/pyupgrade_1_4
...
Some pyupgrade 1.4.x changes
2018-08-23 18:32:53 -07:00
Anthony Sottile
85482d575e
Replace Source with dedent where possible
2018-08-23 09:06:17 -07:00
Anthony Sottile
7099ea9bb0
py.builtin._reraise -> six.reraise
2018-08-22 23:00:58 -07:00
Anthony Sottile
c2cd337886
py.builtin.exec_ => six.exec_
2018-08-22 23:00:06 -07:00
Anthony Sottile
0fc4a806e5
py.builtins._totext -> string literals or six.text_type
2018-08-22 23:00:04 -07:00
Anthony Sottile
8bb8b91357
pyupgrade 1.4: tests
2018-08-22 18:47:21 -07:00
Anthony Sottile
17644ff285
Fix traceback reporting for exceptions with `__cause__` cycles.
2018-08-15 18:15:07 -07:00
Bruno Oliveira
0bb29d5649
Merge pull request #3685 from nicoddemus/merge-master-into-features
...
Merge master into features
2018-07-15 16:53:39 -03:00
Tadek Teleżyński
d2fe619120
Fix truncated locals in verbose mode
2018-07-15 11:30:26 -03:00
Anthony Sottile
af0059079c
Remove unused fix-lint tox environment
2018-07-08 17:05:01 -07:00
Anthony Sottile
f940967e23
Fix test offset after black moved code
2018-06-26 06:35:48 -07:00
Anthony Sottile
cbaa7dd56a
Upgrade pre-commit hooks except pyupgrade
2018-06-26 06:35:27 -07:00
Anthony Sottile
ff19f273a9
Use six to import queue instead of py.builtin._tryimport
2018-06-03 13:12:49 -07:00
Ronny Pfannschmidt
9ed1289b01
run black on test_source_multiline_block.py
2018-05-24 12:12:12 +02:00
Ronny Pfannschmidt
57a55cd0a3
restore formatting of test_source_multiline_block
2018-05-23 20:26:13 +02:00
Ronny Pfannschmidt
d4bf2ff8f5
fix test_source
2018-05-23 18:22:18 +02:00
Ronny Pfannschmidt
3e08c4ee64
sort out flake8 issues and unicode name usage
2018-05-23 18:12:04 +02:00
Ronny Pfannschmidt
703e4b11ba
run black
2018-05-23 16:48:46 +02:00
Ronny Pfannschmidt
9aacb4635e
run pyupgrade
2018-05-23 16:45:09 +02:00
Ville Skyttä
aa51fcb2b6
Spelling and grammar fixes
2018-05-13 12:06:09 +02:00
Anthony Sottile
bd1d17e8de
Replace py.std with stdlib imports
2018-01-09 12:44:10 -08:00
Anthony Sottile
205e29d843
Remove unnecessary `# noqa` comments.
...
Commit automated with https://github.com/asottile/yesqa
2017-12-22 08:29:48 -08:00
Srinivas Reddy Thatiparthy
c2cd239d35
remove _ast reference from test cases as well
2017-12-11 23:24:47 +05:30
Bruno Oliveira
983a09a2d4
Merge remote-tracking branch 'upstream/master' into merge-master-into-features
2017-11-10 18:33:02 -02:00
Bruno Oliveira
b11640c1eb
Fix linting E722: do not use bare except
2017-11-04 13:59:10 -02:00
Bruno Oliveira
03829fde8a
Fix linting E741: ambiguous variable name
2017-11-04 13:59:10 -02:00
hugovk
7113c76f0d
Remove unused import
2017-10-10 09:03:26 +03:00
hugovk
ef732fc51d
Remove code for unsupported Python versions
2017-10-10 08:54:56 +03:00
Bruno Oliveira
abfd9774ef
Remove xfail mark from passing test in py26
2017-09-12 17:59:09 -03:00
Fernando Macedo
59cdef92be
fixes #2731 ReprFuncArgs with mixed unicode and utf-8 args
2017-08-30 16:06:12 -03:00
Jordan Moldow
2e61f702c0
Support PEP-415's Exception.__suppress_context__
...
PEP-415 states that `exception.__context__` should be suppressed
in traceback outputs, if `exception.__suppress_context__` is
`True`.
Now if a ``raise exception from None`` is caught by pytest,
pytest will no longer chain the context in the test report.
The algorithm in `FormattedExcinfo` now better matches the one
in `traceback.TracebackException`.
`Exception.__suppress_context__` is available in all of the
versions of Python 3 that are supported by pytest.
Fixes #2631 .
2017-07-29 02:39:17 -07:00
Bruno Oliveira
22f54784c2
Add "fix-lint" tox environment to fix linting errors
2017-07-20 22:12:15 -03:00
Andras Tim
85141a419f
Fixed E701 flake8 errors
...
multiple statements on one line (colon)
2017-07-17 01:44:23 +02:00
Andras Tim
b9e318866e
Fixed E402 flake8 errors
...
module level import not at top of file
2017-07-17 01:44:23 +02:00
Andras Tim
7248b759e8
Fixed E303 flake8 errors
...
too many blank lines (3)
2017-07-17 01:44:23 +02:00
Andras Tim
b840622819
Fixed E302 flake8 errors
...
expected 2 blank lines, found 0
2017-07-17 01:44:23 +02:00
Andras Tim
17a21d540b
Fixed E301 flake8 errors
...
expected 1 blank line, found 0
2017-07-17 01:44:23 +02:00
Andras Tim
195a816522
Fixed E265 flake8 errors
...
block comment should start with ‘# ‘
2017-07-17 01:44:22 +02:00
Andras Tim
8f3eb6dfc7
Fixed E261 flake8 errors
...
at least two spaces before inline comment
2017-07-17 01:44:22 +02:00
Andras Tim
617e510b6e
Fixed E231 flake8 errors
...
missing whitespace after ‘,’, ‘;’, or ‘:’
2017-07-17 01:44:22 +02:00
Andras Tim
4b22f270a3
Fixed E226 flake8 errors
...
missing whitespace around arithmetic operator
2017-07-17 01:44:22 +02:00
Andras Tim
2e8caefcab
Fixed E225 flake8 errors
...
missing whitespace around operator
2017-07-17 01:44:22 +02:00
Andras Tim
f640e0cb04
Fixed E221 flake8 errors
...
multiple spaces before operator
2017-07-17 01:44:22 +02:00
Andras Tim
ba0a4d0b2e
Fixed E202 flake8 errors
...
whitespace before ‘)’
2017-07-17 01:28:17 +02:00
Andras Tim
df54bf0db5
Fixed E131 flake8 errors
...
continuation line unaligned for hanging indent
2017-07-17 01:28:16 +02:00
Andras Tim
cf97159009
Fixed E128 flake8 errors
...
continuation line under-indented for visual indent
2017-07-17 01:28:16 +02:00
Andras Tim
57438f3efe
Fixed E127 flake8 errors
...
continuation line over-indented for visual indent
2017-07-17 01:28:16 +02:00
Andras Tim
e855a79dd4
Fixed E126 flake8 errors
...
continuation line over-indented for hanging indent
2017-07-17 01:28:16 +02:00