Commit Graph

46 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
Hugo van Kemenade e54c6a1362
Document the --code-highlight default (#9883)
Also normalized all help text using the patterns:

* `One sentence help text`
* `First sentence of help. Second sentence of help.`
2022-05-31 16:32:51 -03:00
Ran Benita a3b69d9d83 Remove py version printing, traceback filtering, freezing
Not so important anymore, and makes it easier to remove the py
dependency.
2021-10-16 12:01:31 +03:00
Bruno Oliveira 109312ba86 Make --version write to stdout rather than stderr
Fix #8246
2021-06-28 15:56:26 -03:00
Bruno Oliveira 7eb0792cba Add pytest.version_tuple
This adds `pytest.version_tuple`, which makes it simpler for users to do something depending on the pytest version, such as declaring hooks which are introduced in later versions.

This feature was added originally in https://github.com/pypa/setuptools_scm/pull/475.

Followup to https://github.com/pytest-dev/pytest/pull/7605.
2021-06-14 09:04:14 -03:00
Christophe Bedard bf9b59b3c8 Add missing space in '--version' help message 2020-12-28 10:50:06 -05:00
Ran Benita 8b220fad4d testing/test_helpconfig: remove unclear comment 2020-12-22 21:08:25 +02:00
Mikhail Fesenko cd9b3618c7
#7942 test_helpconfig.py migrate from testdir to pytester 2020-10-26 18:30:48 +03:00
Anthony Sottile 66bd44c13a py36+: pyupgrade: py36+ 2020-10-03 12:46:54 -07:00
Ran Benita b8471aa527 testing: fix some docstring issues
In preparation for enforcing some docstring lints.
2020-08-03 10:10:43 +03:00
hp310780 27a4c6cd6d
Fix --help crash on add_ini(.., help='') and improve message on help=None (#7427) 2020-07-29 10:48:38 +03:00
Claire Cecil 79701c65ed
Added support for less verbose version information (#7169) 2020-05-23 11:27:58 -03:00
Daniel Hahler 35d136161a add test
Fixes the test to not match e.g. hypothesis (ref: bdde2ac28).

Conflicts:
	testing/test_helpconfig.py
2020-05-19 19:34:08 -03:00
Bruno Oliveira 78baa7b575 Merge remote-tracking branch 'upstream/master' into mm
Conflicts:
	src/_pytest/main.py
	src/_pytest/mark/structures.py
	src/_pytest/python.py
	testing/test_main.py
	testing/test_parseopt.py
2020-02-11 19:22:28 -03: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 4316fe8a92
testing/conftest.py: testdir: set PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 (#6655)
Fixes https://github.com/pytest-dev/pytest/pull/4518.
2020-02-04 02:59:20 +01:00
Daniel Hahler 5049e25a6a tests: cleanup unused fixtures 2020-01-16 21:12:48 +01:00
Ronny Pfannschmidt 2b92fee1c3 initial conversion of exit codes to enum 2019-06-15 06:48:00 +02: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
Anthony Sottile dc75b6af47 Use fix-encoding-pragma pre-commit hook 2019-05-14 15:56:31 -07:00
Anthony Sottile 2368fbb63c Apply reorder-python-imports to all files 2018-10-25 00:01:29 -07:00
Anthony Sottile 8bb8b91357 pyupgrade 1.4: tests 2018-08-22 18:47:21 -07:00
Ronny Pfannschmidt 703e4b11ba run black 2018-05-23 16:48:46 +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 195a816522 Fixed E265 flake8 errors
block comment should start with ‘# ‘
2017-07-17 01:44:22 +02:00
Bruno Oliveira 0baf5e1499 Fix test that expected "unknown hook" error on stderr 2017-04-11 21:55:12 -03:00
Bruno Oliveira 42a5d6bdfa Add __future__ imports to all pytest modules
This prevents silly errors from creeping in Python 2 when testing in Python 3
2017-03-16 22:45:40 -03:00
Dave Hunt ef9dd14963 Introduce pytest command as recommended entry point
Fixes #1629
2016-06-21 16:16:57 +02:00
Bruno Oliveira 2ffd37b816 return non-zero exit code if no tests are collected
Fix #812
Fix #500
2015-08-18 07:35:02 -03:00
holger krekel bddc88f09e adapt to pluggy naming, rename pytest.hookspec_opts to pytest.hookspec,s ame with hookimpl_opts
--HG--
branch : pluggy1
2015-05-06 10:08:08 +02:00
holger krekel 23538bcd31 - some more adaptation to most recent pluggy API
- avoid using pluggin underscore api
- show pluggy version in header

--HG--
branch : pluggy1
2015-05-05 21:53:04 +02:00
holger krekel a8afba054a - refine lsof checking
- make runpytest() create an inline testing process instead of
  a subprocess one

--HG--
branch : testrefactor
2015-04-28 11:54:46 +02:00
holger krekel d2a5c7f99b add documented hookimpl_opts and hookspec_opts decorators
so that one doesn't have to use pytest.mark or function-attribute setting anymore

--HG--
branch : more_plugin
2015-04-25 11:29:11 +02:00
holger krekel 2161b54555 remove overhead for tracing of hook calls and remove some old unused code 2014-10-02 15:25:42 +02:00
holger krekel 351931d5ca call scanning of plugins directly, code is shifted from helpconfig.py to core.py 2014-10-01 12:20:11 +02:00
Jurko Gospodnetić 9fb2079458 replace py.test module references with pytest
The only remaining 'py.test' references are:
 * those referring to the 'py.test' executable
 * those in code explicitly testing py.test/pytest module compatibility
 * those in old CHANGES documentation
 * those in documentation generated based on external data
 * those in seemingly unfinished & unmaintained Japanese documentation

Minor stylistic changes and typo corrections made to documentation next to
several applied py.test --> pytest content changes.
2014-01-18 12:31:33 +01:00
holger krekel 8ac5af2896 fix flakes issues and make --flakes run part of tox runs 2013-10-12 15:39:22 +02:00
holger krekel 5f99511ab7 fix test after ronny's pytest-debug improvements 2012-12-04 20:31:37 +01:00
holger krekel bb07ba7807 rename a number of internal and externally visible variables to use the fixture name
rather than funcargs.  Introduce .funcargnames compatibility attribute for backward compat.
2012-10-05 14:24:44 +02:00
holger krekel 81082ed3d3 extend --help to tell about --markers and --funcargs 2012-09-22 11:44:56 +02:00
holger krekel 650c3bcfde enhance debug tracing: print trace tags at the end of message and forget about "prefix".
Always log to "pytestdebug.log" if "--debug" option is given.
also move related code to pytest_helpconfig plugin.
2011-07-14 19:11:50 +02:00
holger krekel 88cfaebbcb fix issue12 - show plugin versions with "--version" and "--traceconfig" and also document how to add extra information to reporting test header 2011-01-12 19:39:36 +01:00
holger krekel a698465487 streamline docs, especially use "import pytest" and "pytest.*" in python code examples instead of "import py" and "py.test.*". 2010-11-17 22:12:16 +01:00
holger krekel 076e03e90f also un-nest test directory 2010-11-13 11:30:40 +01:00