Gleb Nikonorov
6f8633cc17
add in solution barring documentation
2020-06-13 02:47:15 -04:00
Bruno Oliveira
aaa6f1c3fa
Merge pull request #7330 from gnikonorov/issue_7305
2020-06-12 19:35:38 -03:00
Ran Benita
1cf9405075
Fix some type errors around py.path.local
...
These errors are found using a typed version of py.path.local.
2020-06-12 17:34:31 +03:00
Gleb Nikonorov
95cb7fb676
review feedback
2020-06-10 00:44:22 -04:00
Bruno Oliveira
c17d50829f
Add pyproject.toml support ( #7247 )
2020-06-08 10:03:10 -03:00
Gleb Nikonorov
2a3c21645e
Commit solution thus far, needs to be polished up pre PR
2020-06-06 02:38:18 -04:00
Ran Benita
54ad048be7
Enable check_untyped_defs mypy option for testing/ too
2020-06-05 11:34:20 +03:00
Bruno Oliveira
8ac18bbecb
Show invalid ini keys sorted
...
Otherwise this relies on the dictionary order of `config.inicfg`, which
is insertion order in py36+ but "random" order in py35.
2020-06-02 16:01:47 -03:00
Gleb Nikonorov
db203afba3
Add in --strict-config flag to force warnings to errors
2020-05-31 02:45:40 -04:00
Gleb Nikonorov
8f2c2a5dd9
Add test case for invalid ini key in different section header
2020-05-31 00:49:21 -04:00
Gleb Nikonorov
eef4f87e7b
Output a warning to stderr when an invalid key is read from an INI config file
2020-05-30 20:36:02 -04:00
Claire Cecil
79701c65ed
Added support for less verbose version information ( #7169 )
2020-05-23 11:27:58 -03:00
Bruno Oliveira
9e1e7fcabe
Use a nice string repr for ConftestImportFailure
...
The default message is often hard to read:
E _pytest.config.ConftestImportFailure: (local('D:\\projects\\pytest\\.tmp\\root\\foo\\conftest.py'), (<class 'RuntimeError'>, RuntimeError('some error',), <traceback object at 0x000001CCC3E39348>))
Using a shorter message is better:
E _pytest.config.ConftestImportFailure: RuntimeError: some error (from D:\projects\pytest\.tmp\root\foo\conftest.py)
And we don't really lose any information due to exception chaining.
2020-05-17 11:26:30 -03:00
Bruno Oliveira
6c2d358918
Merge pull request #7135 from pytest-dev/terminalwriter
2020-05-06 18:26:44 -03:00
Ran Benita
abf785666a
testing: fix lint after merge of old branch
2020-05-05 22:00:55 +03:00
Ran Benita
a8dbb32a6b
Merge pull request #6797 from blueyed/tests-simpler
...
tests: simplify test_pytest_plugins_in_non_top_level_conftest_…
2020-05-05 21:51:50 +03:00
Ran Benita
46d768503e
Merge pull request #6839 from blueyed/typing-get_dirs_from_args-parseconfig
...
typing: get_dirs_from_args, parseconfig
2020-05-05 21:11:26 +03:00
Ran Benita
414a87a53f
config/argparsing: use our own get_terminal_width()
2020-04-30 16:44:03 +03:00
Daniel Hahler
dc86fb6758
pre-commit run --all-files
2020-03-07 23:47:55 +01:00
Daniel Hahler
6c236767e0
Adjust/fix test_config: use strs with determine_setup
2020-02-28 20:40:39 +01:00
Daniel Hahler
5819536f00
Improve UsageError with invalid `-o` style ( #6795 )
...
This started from fixing the test, where `"xdist_strict True"` was used
as a single argument, although you typically would see `["xdist_strict",
"True"]`.
Improves the error message to mention the option that caused the error.
2020-02-28 19:41:56 +01:00
Daniel Hahler
bfd0d18371
tests: test_config: move tests ( #6796 )
...
Originally added in a2891420d
(with `TestRootdir`), but then
accidentally moved to `TestOverrideIniArgs` in 802755cee
.
2020-02-23 17:12:55 +01:00
Daniel Hahler
077001fe5c
tests: simplify test_pytest_plugins_in_non_top_level_conftest_unsupported_no_false_positives
2020-02-22 23:31:37 +01:00
Daniel Hahler
d1b50526fa
tests: harden some UsageError tests (matching the error msg) ( #6775 )
2020-02-20 13:29:59 +01:00
Daniel Hahler
de3353aac1
test_load_initial_conftest_last_ordering: handle testing package ( #6706 )
2020-02-14 16:58:17 +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
75714ee707
pluginmanager.consider_preparse: add exclude_only kwarg ( #6443 )
...
Plugins specified with ``-p`` are now loaded after internal plugins, which
results in their hooks being called *before* the internal ones.
This makes the ``-p`` behavior consistent with ``PYTEST_PLUGINS``.
* fix/adjust test_disable_plugin_autoload
* adjust test_plugin_loading_order
2020-02-03 14:10:54 +01:00
Daniel Hahler
00097df5cd
tests: add test_plugin_loading_order
...
Ref: https://github.com/pytest-dev/pytest/pull/6443
2020-01-23 11:57:12 +01:00
Daniel Hahler
118cb3d3be
Fix test_config: wrong assertions, lint, unused fixtures
2020-01-16 19:27:46 +01:00
Daniel Hahler
117072d64c
typing: fix _pytest.config.findpaths.determine_setup
2020-01-13 11:45:20 +01:00
Bruno Oliveira
c7f9fda42d
Fix assertion rewriting module detection for egg dists
...
Fix #6301
2019-12-04 15:30:45 -03:00
Daniel Hahler
5979837c60
Import Path from _pytest.pathlib for py35
...
This is important for `isinstance` checks etc.
2019-11-15 22:19:53 +01:00
Daniel Hahler
2f589a9769
pytester: runpytest_inprocess: use splitlines()
...
This avoids having a trailing empty lines always.
2019-10-23 04:34:29 +02:00
Bruno Oliveira
d12cdd3127
Make InvocationParams.args a tuple
...
This avoids mutating the original list to reflect on InvocationParams,
which is supposed to be an immutable snapshot of the state of pytest.main()
at the moment of invocation (see pytest-dev/pytest-xdist#478 ).
2019-10-19 16:42:58 -03:00
Daniel Hahler
2a6a1ca07d
Inject width via pylib to argparse formatter
...
`argparse.HelpFormatter` looks at `$COLUMNS` only, falling back to a
default of 80.
`py.io.get_terminal_width()` is smarter there, and could even work
better with https://github.com/pytest-dev/py/pull/219 .
This ensures to use a consistent value for formatting the ini values etc.
2019-08-17 16:51:02 +02: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
Bruno Oliveira
a82dd2f064
Fix linting
2019-07-23 10:55:22 -03:00
Florian Bruhin
8c47db724c
Improve output when parsing an ini configuration fails
2019-07-23 15:27:27 +02:00
Daniel Hahler
3c7438969a
Replace internal config._origargs with invocation_params.args
...
Added in https://github.com/pytest-dev/pytest/pull/5564 .
2019-07-23 06:46:56 +02:00
Bruno Oliveira
602cd5e21f
Introduce Config.invocation_params ( #5564 )
...
Introduce Config.invocation_params
2019-07-10 07:46:34 -03:00
Bruno Oliveira
31738155b5
Remove deprecated features ( #5529 )
...
Remove deprecated features
2019-07-09 19:04:06 -03:00
Bruno Oliveira
4cda7093f6
Add note about PYTEST_ADDOPTS
2019-07-06 17:27:54 -03:00
Bruno Oliveira
6a9bf2852a
Apply review suggestions: use a simple struct for invocation params
2019-07-06 12:22:19 -03:00
Bruno Oliveira
3e669a262a
Introduce Config.invocation_args and Config.invocation_plugins
...
These attributes can be used to access the unchanged arguments passed
to pytest.main().
The intention is to use these attributes to initialize workers in
the same manner as the master node is initialized in pytest-xdist.
2019-07-05 19:45:23 -03:00
Miro Hrončok
c54cbd63c8
Replace importlib_metadata with importlib.metadata on Python 3.8+
...
Fixes https://github.com/pytest-dev/pytest/issues/5537
2019-07-04 15:00:10 +02:00
Bruno Oliveira
f2b7809d5d
Move setup.cfg error message and tests to an appropriate location
...
Those are not really deprecated anymore and are part of the normal
code for config
2019-06-30 13:18:07 -03:00
Bruno Oliveira
647d89c444
Move code about 'pytest_plugins' error to a more appropriate place
...
It is no longer deprecated, but part of the normal code for 'config'
2019-06-30 13:18:07 -03:00
Anthony Sottile
4e723d6750
Fix crash when discovery fails while using `-p no:terminal`
2019-06-27 10:24:29 -07:00
Ronny Pfannschmidt
2b92fee1c3
initial conversion of exit codes to enum
2019-06-15 06:48:00 +02:00
Bruno Oliveira
883db6a216
Add test for packages with broken metadata
...
Related to #5389
2019-06-04 17:04:15 -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
Daniel Hahler
e032904413
Merge master into features
2019-05-28 01:46:16 +02:00
Anthony Sottile
13f02af97d
Switch to importlib-metadata
2019-05-27 13:24:08 -07:00
Bruno Oliveira
66f20b6f5e
Fix invalid Python file encoding "utf8" ( #5252 )
...
Fix invalid Python file encoding "utf8"
2019-05-23 20:24:23 -03:00
Daniel Hahler
93fd9debe3
Allow disabling of python plugin
...
Fixes https://github.com/pytest-dev/pytest/issues/5277 .
2019-05-17 18:17:14 +02:00
Anthony Sottile
dc75b6af47
Use fix-encoding-pragma pre-commit hook
2019-05-14 15:56:31 -07:00
Daniel Hahler
65133018f3
Terminal plugin is not semi-essential anymore
...
Thanks to https://github.com/pytest-dev/pytest/pull/5138 .
2019-04-27 03:39:00 +02:00
Daniel Hahler
7f519f8ab7
Merge master into features
2019-04-27 00:43:00 +02:00
Ilya Konstantinov
d67d68f6d3
Eliminate core dependency on 'terminal' plugin
2019-04-17 11:19:19 -07:00
Daniel Hahler
8b2fcf517c
Merge master
2019-04-11 13:28:36 +02:00
Daniel Hahler
8011ff5bda
Add _sys_snapshot fixture and use it with more tests
2019-04-05 11:55:23 +02:00
Daniel Hahler
8c734dfc2f
Split out list of essential plugins
...
Fixes https://github.com/pytest-dev/pytest/issues/4976 .
2019-04-02 14:39:56 +02:00
Daniel Hahler
e7ade066b6
Merge pull request #5011 from blueyed/merge-master-into-features
...
Merge master into features
2019-03-29 18:35:13 +01:00
Daniel Hahler
4e931b258d
Merge master into features
2019-03-29 11:05:46 +01:00
Daniel Hahler
bfda2a0050
setup.cfg: use existing [tool:pytest] (ignoring [pytest])
2019-03-29 10:59:27 +01:00
Daniel Hahler
d17ea7a9c0
tests: ensure cleanup with configs via get_config()
...
Also done in test_pluginmanager, although no resource warnings are
there at least.
Fixes https://github.com/pytest-dev/pytest/issues/4355 .
2019-03-28 00:14:13 +01:00
Daniel Hahler
08f3b02dfc
tests: fnmatch_lines: use list
...
For strings fnmatch_lines converts it into a Source objects, splitted on
newlines. This is not necessary here, and it is more consistent to use
lists here in the first place.
2019-03-23 11:36:18 +01:00
Daniel Hahler
553951c443
Fix some issues related to "-p no:X" with default_plugins
2019-03-21 17:01:50 +01:00
Daniel Hahler
c7c120fba6
terminal: handle "capture" option not being available
...
This is the case with `-p no:capture` now.
2019-03-20 03:01:26 +01:00
Daniel Hahler
415899d428
config: handle `-p no:plugin` with default plugins
...
`-p no:capture` should not load its fixtures in the first place.
2019-03-20 02:47:13 +01:00
Bruno Oliveira
0deb7b1696
Do not show "inifile:" string if there's no configuration file
2019-03-02 11:45:08 -03:00
Bruno Oliveira
a0207274f4
-p option now can be used to early-load plugins by entry-point name
...
Fixes #4718
2019-02-24 13:20:17 -03:00
Bruno Oliveira
a68f4fd2b9
Fix test failures after pluggy 1.8 release
...
pluggy now calls iter_entry_points with different arguments, and tests
which mocked that call need to be updated accordingly.
2019-02-22 18:58:54 -03:00
Daniel Hahler
f13935da53
Display --help/--version with ArgumentErrors
2019-02-11 15:49:48 +01:00
Bruno Oliveira
b7e8171cf8
Merge branch 'features' into remove-legacy-warn
2018-12-17 10:37:31 -02:00
Daniel Hahler
8e287c5c77
Merge master into features
2018-12-14 16:44:43 +01:00
Bruno Oliveira
fd48cd57f9
Remove config.warn, Node.warn; pytest_logwarning issues a warning when implemented
...
Fix #3078
2018-12-14 12:50:18 -02:00
Daniel Hahler
6af674a3ac
Merge pull request #4520 from blueyed/PYTEST_DISABLE_PLUGIN_AUTOLOAD-del
...
tests: fix tests that require PYTEST_DISABLE_PLUGIN_AUTOLOAD to be unset
2018-12-12 18:40:46 +01:00
Daniel Hahler
0db5ccb0dd
Merge master into features
2018-12-10 05:42:07 +01:00
Daniel Hahler
f3babf13ea
Ensure that PYTEST_ADDOPTS are valid by themselves
...
Fixes https://github.com/pytest-dev/pytest/issues/4265 .
2018-12-09 21:57:10 +01:00
Daniel Hahler
64ee1ee81b
tests: fix tests that require PYTEST_DISABLE_PLUGIN_AUTOLOAD to be unset
...
Fix pytest's own tests with PYTEST_DISABLE_PLUGIN_AUTOLOAD=1.
2018-12-09 12:06:18 +01:00
Anthony Sottile
1bba0a9714
Deprecate `raises(..., 'code(as_a_string)')` / `warns(..., 'code(as_a_string)')
2018-11-29 09:34:51 -08:00
Bruno Oliveira
dc20dedbc7
Change RemovedInPytest4Warnings to errors by default
...
To keep existing tests which emit RemovedInPytest4Warnings running, decided
to go with a command line option because:
* Is harder to integrate an ini option with tests which already use an ini file
* It also marks tests which need to be removed/updated in 4.1, when
RemovedInPytest4Warning and related functionality are removed.
Fix #3737
2018-11-12 16:10:57 -02:00
Daniel Hahler
4a74d455de
minor: typos
2018-11-09 02:03:44 +01:00
Anthony Sottile
2368fbb63c
Apply reorder-python-imports to all files
2018-10-25 00:01:29 -07:00
Bruno Oliveira
b7560a8808
Keep backward compatibility for code as kw in Node.warn
2018-09-04 16:48:21 -03:00
Bruno Oliveira
47bf58d69e
Make Node.warn support two forms, new and deprecated
...
As suggested during review, it now accepts two forms:
Node.warn(warning_instance) (recommended)
Node.warn(code, message) (deprecated)
2018-09-04 15:53:17 -03:00
Bruno Oliveira
78ac7d99f5
Deprecate Config.warn and Node.warn, replaced by standard warnings
2018-09-04 11:35:34 -03:00
Bruno Oliveira
2f2d5861bb
Merge remote-tracking branch 'upstream/master' into merge-master-into-features
2018-08-26 16:45:00 -03:00
Anthony Sottile
85482d575e
Replace Source with dedent where possible
2018-08-23 09:06:17 -07:00
Bruno Oliveira
c64a8c9c7f
Merge remote-tracking branch 'upstream/master' into merge-master-into-features
2018-08-18 15:54:53 -03:00
Virgil Dupras
126896f69d
Add option to disable plugin auto-loading
...
If `PYTEST_DISABLE_PLUGIN_AUTOLOAD` is set, disable auto-loading of
plugins through setuptools entrypoints. Only plugins that have been
explicitly specified are loaded.
ref #3784 .
2018-08-07 13:16:28 -04:00
Bruno Oliveira
2c0d2eef40
Only consider actual functions when considering hooks
...
Fix #3775
2018-08-04 16:37:07 -03:00
Anthony Sottile
cbaa7dd56a
Upgrade pre-commit hooks except pyupgrade
2018-06-26 06:35:27 -07:00
Ronny Pfannschmidt
464117b472
fix imports in tests
2018-06-05 10:20:36 +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