Commit Graph

82 Commits

Author SHA1 Message Date
Pierre Sassoulas 4588653b24 Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff
ruff is faster and handle everything we had prior.

isort configuration done based on the indication from
https://github.com/astral-sh/ruff/issues/4670, previousely based on
reorder-python-import (#11896)

flake8-docstrings was a wrapper around pydocstyle (now archived) that
explicitly asks to use ruff in https://github.com/PyCQA/pydocstyle/pull/658.

flake8-typing-import is useful mainly for project that support python 3.7
and the one useful check will be implemented in https://github.com/astral-sh/ruff/issues/2302

We need to keep blacken-doc because ruff does not handle detection
of python code inside .md and .rst. The direct link to the repo is
now used to avoid a redirection.

Manual fixes:
- Lines that became too long
- % formatting that was not done automatically
- type: ignore that were moved around
- noqa of hard to fix issues (UP031 generally)
- fmt: off and fmt: on that is not really identical
  between black and ruff
- autofix re-order in pre-commit from faster to slower

Co-authored-by: Ran Benita <ran@unusedvar.com>
2024-02-02 09:27:00 +01:00
Bruno Oliveira 878af85aef
mypy: disallow untyped defs by default (#11862)
Change our mypy configuration to disallow untyped defs by default, which ensures *new* files added to the code base are fully typed.

To avoid having to type-annotate everything now, add `# mypy: allow-untyped-defs` to files which are not fully type annotated yet.

As we fully type annotate those modules, we can then just remove that directive from the top.
2024-01-28 10:12:42 -03:00
Ben Brown 12b9bd5801
Fix teardown error reporting when `--maxfail=1` (#11721)
Co-authored-by: Ran Benita <ran@unusedvar.com>
2024-01-03 19:39:24 +02:00
Ran Benita 385796ba49 Rework Session and Package collection
Fix #7777.
2023-12-10 17:01:39 +02:00
Zac Hatfield-Dodds 661b938fca Add encoding in more tests 2023-06-20 04:55:40 -07:00
Ran Benita 43213add57 testing/test_session: add a regression test for an old bug
Nothing tests this currently. Make sure it doesn't regress if/when the
complex code in `Session.collect` is cleaned up.
2021-11-15 23:22:54 +02:00
Ran Benita 062d91ab47
python: remove the `Instance` collector node 2021-11-13 14:03:44 +02:00
duthades b815f430e5 #7942 test_session.py migrate from testdir to pytester
- Add name to AUTHORS
2020-11-04 21:55:07 +05:30
Anthony Sottile 66bd44c13a py36+: pyupgrade: py36+ 2020-10-03 12:46:54 -07:00
Daniel Hahler 952cab2d85
Simplify test_rootdir_wrong_option_arg (#6812) 2020-02-28 18:38:07 +01:00
Ran Benita d33da078a8 Move ExitCode's definition from _pytest.main to _pytest.config
ExitCode is used in several internal modules and hooks and so with type
annotations added, needs to be imported a lot.

_pytest.main, being the entry point, generally sits at the top of the
import tree.

So, it's not great to have ExitCode defined in _pytest.main, because it
will cause a lot of import cycles once type annotations are added (in
fact there is already one, which this change removes).

Move it to _pytest.config instead.

_pytest.main still imports ExitCode, so importing from there still
works, although external users should really be importing from `pytest`.
2020-02-10 23:55:06 +02: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
Ronny Pfannschmidt 2b92fee1c3 initial conversion of exit codes to enum 2019-06-15 06:48:00 +02: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
Daniel Hahler e032904413 Merge master into features 2019-05-28 01:46:16 +02:00
Anthony Sottile dc75b6af47 Use fix-encoding-pragma pre-commit hook 2019-05-14 15:56:31 -07:00
Daniel Hahler c081c01eb1 minor: s/no covers/no cover/ 2019-05-14 06:51:49 +02:00
Nikolay Kondratyev bc00d0f7db Fix handle repr error with showlocals and verbose output 2019-04-19 18:54:21 +03:00
Daniel Hahler e1ae469504 Merge master into features 2019-03-26 10:23:21 +01:00
Daniel Hahler 4148663706
Merge pull request #4979 from blueyed/minor
Minor: whitespace, typo, docs
2019-03-26 10:01:13 +01:00
Daniel Hahler 6352cf2374 test_implicit_bad_repr1: harden/cleanup 2019-03-24 11:15:40 +01:00
Daniel Hahler 3127ec737b Fix pytest's own tests with `-W error::ResourceWarning` 2019-03-24 11:05:00 +01:00
Daniel Hahler afa985c135 Revisit coverage in some tests 2019-03-22 17:26:16 +01:00
Bruno Oliveira 0deb7b1696 Do not show "inifile:" string if there's no configuration file 2019-03-02 11:45:08 -03:00
Christian Fetzer fc5d4654e5 Add ability to exclude files matching glob patterns with --ignore-glob
This adds the `--ignore-glob` option to allow Unix-style wildcards so
that `--ignore-glob=integration*` excludes all tests that reside in
files starting with `integration`.

Fixes: #3711
2019-02-06 11:29:30 +01:00
Anthony Sottile 16546b7342 Remove some dead code
- I wrote a thing: https://github.com/asottile/dead
- wanted to try it out, there's lots of false positives and I didn't look
  through all the things it pointed out but here's some
2019-01-13 20:41:30 -08:00
Ronny Pfannschmidt 7eb28f9eb7 remove yield tests and compat properties 2018-11-30 10:40:13 +01: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 950d30e6e0 fix #4400 - rearrange the handling of yield test warnings/errors 2018-11-16 13:49:46 +01:00
Bruno Oliveira 557cb6cffe Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2018-11-13 09:01:37 -02:00
Daniel Hahler 87254ca593 Add test for --deselect without "::()"
Closes: https://github.com/pytest-dev/pytest/issues/4127.
2018-11-10 23:46:41 +01:00
Daniel Hahler bee72a6622 Fix nodes._check_initialpaths_for_relpath for dirs
Ref: https://github.com/pytest-dev/pytest/issues/4321#issuecomment-436951894

Hardens some of the not many tests affected by this:

1. `testing/test_session.py::test_rootdir_option_arg` displayed:

> root/test_rootdir_option_arg2/test_rootdir_option_arg.py

2. `test_cmdline_python_namespace_package` displayed "hello/" prefix for:

> hello/test_hello.py::test_hello
> hello/test_hello.py::test_other
2018-11-09 13:16:59 +01:00
Daniel Hahler d65f300988 Move handling of duplicate files
This removes the hack added in https://github.com/pytest-dev/pytest/pull/3802.

Adjusts test:

- it appears to not have been changed to 7 intentionally.
- removes XXX comment, likely not relevant anymore since 6dac7743.
2018-11-01 13:06:36 -04:00
Bruno Oliveira 8d0e1a99e4
Merge pull request #4241 from blueyed/move-duplicates
Move handling of duplicate files
2018-10-26 08:07:48 -03:00
Daniel Hahler e041823643 Move handling of duplicate files
This removes the hack added in https://github.com/pytest-dev/pytest/pull/3802.

Adjusts test:

- it appears to not have been changed to 7 intentionally.
- removes XXX comment, likely not relevant anymore since 6dac7743.
2018-10-25 20:48:08 +02:00
Anthony Sottile 2368fbb63c Apply reorder-python-imports to all files 2018-10-25 00:01:29 -07:00
Anthony Sottile cbaa7dd56a Upgrade pre-commit hooks except pyupgrade 2018-06-26 06:35:27 -07:00
Ronny Pfannschmidt 703e4b11ba run black 2018-05-23 16:48:46 +02:00
Jordan Speicher 774c539f1a Add --deselect command line option
Fixes #3198
2018-02-16 08:17:37 -06:00
feuillemorte 3eb6cad222 #1642 Fix comments 2018-02-01 11:20:37 +03:00
feuillemorte 936651702b #1642 Fix tests 2018-02-01 00:27:48 +03:00
feuillemorte 741b571f3b #1642 fix tests and config.py 2018-02-01 00:03:24 +03:00
feuillemorte 0cfa975930 #1642 Fix tests 2018-01-25 15:57:04 +03:00
feuillemorte 83034bbd48 #1642 Fix rootdir option 2018-01-20 22:30:01 +03:00
feuillemorte 4a18d76160 #1642 remove print 2018-01-17 23:14:40 +03:00
feuillemorte d784155fd2 #1642 Add rootdir option 2018-01-17 23:02:31 +03:00
Bruno Oliveira 03829fde8a Fix linting E741: ambiguous variable name 2017-11-04 13:59:10 -02:00
Andras Tim b49e8baab3 Fixed E731 flake8 errors
do not assign a lambda expression, use a def
2017-07-17 01:44:23 +02:00