Commit Graph

12506 Commits

Author SHA1 Message Date
Ran Benita 23c9856857 Remove no longer needed noqa's 2020-05-12 09:29:47 +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 d1534181c0 pre-commit: upgrade flake8 3.7.7 -> 3.8.1
New errors:

    testing/test_setupplan.py:104:15: E741 ambiguous variable name 'l'
    testing/test_setupplan.py:107:15: E741 ambiguous variable name 'l'
    extra/get_issues.py:48:29: E741 ambiguous variable name 'l'
    testing/test_error_diffs.py:270:32: E741 ambiguous variable name 'l'

Not so sure about it but easier to just fix.

But more importantly, is a large amount of typing-related issues there
were fixed which necessitated noqa's which can now be removed.
2020-05-12 09:29:40 +03:00
Hunter Richards 06b6d5b1d5 Combine all mentions of `yield` into "Unsupported" section 2020-05-11 15:36:08 -05:00
Ran Benita 15d5e8cd97
Merge pull request #7210 from bluetech/minus-k-deprecations
mark: deprecate a couple undocumented -k syntaxes
2020-05-11 20:57:35 +03:00
Ran Benita c4f9eaa5de mark: deprecate a couple undocumented -k syntaxes
The `-k '-expr'` syntax is an old alias to `-k 'not expr'`. It's also
not a very convenient to have syntax that start with `-` on the CLI.
Deprecate it and suggest replacing with `not`.

---

The `-k 'expr:'` syntax discards all items until the first match and
keeps all subsequent, e.g. `-k foo` with

    test_bar
    test_foo
    test_baz

results in `test_foo`, `test_baz`. That's a bit weird, so deprecate it
without a replacement. If someone complains we can reconsider or devise
a better alternative.
2020-05-11 16:07:52 +03:00
Zac Hatfield-Dodds 0ba6e1f74e
Merge pull request #7209 from pwilczynskiclearcode/master
#7138 Docs improvement: Apply indirect on particular arguments
2020-05-11 22:10:28 +10:00
Paweł Wilczyński dbfc629698 #7138 Docs improvement: Apply indirect on particular arguments 2020-05-11 13:26:16 +02:00
Pavel Karateev 8bd3f1a72b
Better test method name
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-05-10 16:59:20 +03:00
Pavel Karateev 17857b67df
Better changelog wording
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-05-10 16:58:22 +03:00
Pavel Karateev 184528d0c2 Fix tests to expected repr output 2020-05-10 13:06:36 +03:00
Pavel Karateev 7b196747dd Use saferepr for all types 2020-05-10 12:47:26 +03:00
Pavel Karateev 6b26f0f890 Rename test method and reference issue 2020-05-10 12:19:52 +03:00
Pavel Karateev feb7a5f0d1 Omit internal solution details 2020-05-10 12:11:59 +03:00
Pavel Karateev a2280d39ec #7126, use past tense in changelog 2020-05-09 14:14:23 +03:00
Pavel Karateev 903e2ab6ee Fix #7126 - saferepr for bytes params
bytes parametrize parameters cause error when --setup-show is used
and Python is called with -bb flag
2020-05-09 13:57:17 +03:00
Bruno Oliveira 5e7f1ab4bf
Merge pull request #7201 from nicoddemus/bruno-tidelift 2020-05-08 13:28:14 -03:00
Anthony Sottile abb047f71b
Add asottile as well
(went for alphabetical order, hope that's ok!)
2020-05-08 08:57:22 -07:00
Bruno Oliveira 97a0239aad Add myself to TIDELIFT 2020-05-08 12:36:40 -03:00
Bruno Oliveira 741a8b8023
Merge pull request #7195 from nicoddemus/cherry-pick-release 2020-05-08 09:09:48 -03:00
Bruno Oliveira b02b0b610b
Merge pull request #6989 from blueyed/fix-test 2020-05-08 09:04:59 -03:00
Bruno Oliveira e6151cd8d0 Cherry-pick release 5.4.2 2020-05-08 09:03:21 -03:00
Bruno Oliveira 5dd987e10f
Merge pull request #6999 from bluetech/simplify-fixture-compat 2020-05-08 08:06:35 -03:00
Bruno Oliveira 9657798c12
Merge pull request #7158 from CarycaKatarzyna/issue_7076 2020-05-08 07:56:03 -03:00
Ran Benita 857b5c9ccd
Merge pull request #7185 from bluetech/sigpipe
Handle SIGPIPE/BrokenPipeError in pytest's CLI
2020-05-08 13:32:34 +03:00
Ran Benita c66bf59fd5
ci: update github action versions, remove outdated comment (#7177) 2020-05-08 13:03:51 +03:00
Bruno Oliveira a039fe3e92
Merge pull request #7187 from asottile/update-contributing 2020-05-08 06:58:37 -03:00
Ran Benita 73448f265d Handle EPIPE/BrokenPipeError in pytest's CLI
Running `pytest | head -1` and similar causes an annoying error to be
printed to stderr:

    Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
    BrokenPipeError: [Errno 32] Broken pipe

(or possibly even a propagating exception in older/other Python versions).

The standard UNIX behavior is to handle the EPIPE silently. To
recommended method to do this in Python is described here:
https://docs.python.org/3/library/signal.html#note-on-sigpipe

It is not appropriate to apply this recommendation to `pytest.main()`,
which is used programmatically for in-process runs. Hence, change
pytest's entrypoint to a new `pytest.console_main()` function, to be
used exclusively by pytest's CLI, and add the SIGPIPE code there.

Fixes #4375.
2020-05-08 12:51:02 +03:00
Anthony Sottile 9d2eabb397
Merge pull request #7186 from asottile/is_setup_py_encoding_agnostic
Fix _is_setup_py for files encoded differently than locale
2020-05-07 14:01:28 -07:00
Anthony Sottile 9926fcf452 remove incorrect note about requiring admin install 2020-05-07 13:51:20 -07:00
Bruno Oliveira 63e94b986b
Merge pull request #7179 from asottile/py39 2020-05-07 17:42:57 -03:00
Anthony Sottile b238845d0f Fix _is_setup_py for files encoded differently than locale 2020-05-07 13:14:58 -07:00
Ran Benita de556f895f
testing: clean up parametrization in test_mark.py (#7184) 2020-05-07 20:42:04 +03:00
Ran Benita 32c00db0bf
Merge pull request #7176 from bluetech/warnings-optimize-parse
warnings: speed up work done in catch_warnings_for_item()
2020-05-07 19:34:28 +03:00
Anthony Sottile dad328bc8a Fix tests for python3.9 2020-05-07 05:26:55 -07:00
Ran Benita 65963d2066 warnings: speed up work done in catch_warnings_for_item()
When setting up the warnings capture, filter strings (with the general
form `action:message:category:module:line`) are collected from the
cmdline, ini and item and applied. This happens for every test and other
cases.

To apply a string it needs to be parsed into a tuple, and it turns out
this is slow. Since we already vendor the parsing code from Python's
warnings.py, we can speed it up by caching the result. After splitting
the parsing part from the applying part, the parsing is pure and is
straightforward to cache.

An alternative is to parse ahead of time and reuse the result, however
the caching solution turns out cleaner and more general in this case.

On this benchmark:

    import pytest
    @pytest.mark.parametrize("x", range(5000))
    def test_foo(x): pass

Before:

============================ 5000 passed in 14.11s =============================
         14365646 function calls (13450775 primitive calls) in 14.536 seconds

After:

============================ 5000 passed in 13.61s =============================
         13290372 function calls (12375498 primitive calls) in 14.034 seconds
2020-05-07 12:19:13 +03:00
Ran Benita 81da5dac48
Merge pull request #7122 from bluetech/matcher-parser
Stop using Python's eval() for -m and -k
2020-05-07 09:23:29 +03:00
Bruno Oliveira 6c2d358918
Merge pull request #7135 from pytest-dev/terminalwriter 2020-05-06 18:26:44 -03:00
Bruno Oliveira 4d439760ad
Merge pull request #7168 from nicoddemus/saferepr-getattr-fail-7145 2020-05-06 17:57:38 -03:00
Bruno Oliveira 199f45d0a9
Merge pull request #7027 from blueyed/doc-rm-rm 2020-05-06 12:43:51 -03:00
Ran Benita d16ae0bbdc
Merge pull request #7171 from bluetech/code-import-cycles
code: fix import cycles between code.py and source.py
2020-05-06 18:15:32 +03:00
Ran Benita 8c2c297e1e
Merge pull request #7172 from bluetech/micro-optimizations-1
Some easy micro optimizations to collection
2020-05-06 18:13:44 +03:00
Ran Benita 89eee90b5f python: optimize PythonCollector.collect 2020-05-06 12:05:04 +03:00
Ran Benita b90f34569f nodes: micro-optimize Node attribute access 2020-05-06 11:58:30 +03:00
Ran Benita 5702c86f4c nodes: micro-optimize hash(node)
Turns out it's called alot, and saving the function call makes it
faster.
2020-05-06 11:58:30 +03:00
Ran Benita fcc473ab1c Use dict instead of OrderedDict on Python 3.7
OrderedDict is quite a bit heavier than just a dict.
2020-05-06 11:58:28 +03:00
Ran Benita 69143fe5b0 code: fix import cycles between code.py and source.py
These two files were really intertwined. Make it so code.py depends on
source.py without a reverse dependency.

No functional changes.
2020-05-06 11:01:32 +03:00
Bruno Oliveira d0022b5a13 'saferepr' handles classes with broken __getattribute__
Fix #7145
2020-05-05 19:22:39 -03:00
Ran Benita 4787fd64a4
Merge pull request #7167 from bluetech/lint-merge-fix
testing: fix lint after merge of old branch
2020-05-05 23:34:05 +03:00
Ran Benita 94400a68b4 terminal: fix non-deterministic warning summary order in Python 3.5
In Python 3.5, collections.Counter() does not preserve insertion order.
2020-05-05 23:08:44 +03:00