Commit Graph

2586 Commits

Author SHA1 Message Date
Bruno Oliveira 459e10b802
Merge pull request #9133 from okken/9113_deselected_assert_outcomes 2021-10-05 16:50:42 -03:00
Ran Benita c4b9b14a44 mark/structures: micro-optimize item.keywords/NodeKeywords 2021-10-05 16:50:22 +03:00
Ran Benita 6a5211f369 rewrite: fixup end_lineno, end_col_offset of rewritten asserts
These are new additions in Python 3.8:
https://docs.python.org/3/whatsnew/3.8.html#ast
I'm not sure what's using them but we should set them anyway.
2021-10-05 10:51:09 +03:00
Brian Okken c82bda259c
Add a `pythonpath` setting to allow paths to be added to `sys.path`. (#9134) 2021-10-05 09:36:38 +03:00
Zac Hatfield-Dodds e763fde482
Merge pull request #9158 from hoefling/doc/internal-crossrefs
replace hardcoded urls to docs.pytest.org with internal crossrefs, add crossrefs to numpy docs, use sphinx pep role
2021-10-05 08:43:19 +11:00
Ran Benita e5468681b0 Use attr.s(auto_attribs=True) in more places
It's nicer to read without the attr.ib noise.
2021-10-04 19:24:12 +03:00
Ran Benita dced00e60f
Merge pull request #9154 from bluetech/refactor-callspec2
python: refactor CallSpec2
2021-10-04 18:56:29 +03:00
Ran Benita 570b1facb7 python: refactor CallSpec2
This type is semi-private; not documented but many plugins access it
through `item.callspec`. However, plugins access the public fields and
almost none try to construct or monkeypatch it. So we should be allowed
to clean it up some.

- Convert to attrs, add slots and frozen

- Instead of doing `new = old.copy(); new.setmulti2()`, do `new =
  old.setmulti()`. This is cleaner and faster.

- Remove the `metafunc` attribute. This causes a reference cycle
  (multifunc._calls -> callspec -> multifunc) for no good reason --
  neither pytest itself or plugins access this attribute, so let's not
  keep the Metafunc objects alive past their due.

- Some comments.

I would have also like to make the dicts and lists themselves immutable,
however some plugins mess with those so that should be done separately,
if at all.
2021-10-04 17:33:52 +03:00
oleg.hoefling d58ee2b677
replace hardcoded urls to docs.pytest.org with internal crossrefs, add external crossrefs where possible
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-10-04 00:23:41 +02:00
Ran Benita 637e8efdd4 mark/structures: slightly optimize some functions
`normalize_mark_list` shows up in pandas collection profiles. It's
simple enough to improve.
2021-10-02 14:06:52 +03:00
Ran Benita 8af558723e
main: avoid Path(Path(...)) calls, they're slow (#9147) 2021-10-01 16:21:32 +03:00
Ran Benita 5fc3e35afb
Merge pull request #9144 from bluetech/py36_order_by_definition
py36+ tests are definition ordered [v2]
2021-10-01 16:17:37 +03:00
Ran Benita d8831c64eb
Merge pull request #9148 from bluetech/lru-cache-method
Avoid `@lru_cache` on methods
2021-10-01 16:16:51 +03:00
Ran Benita c86ceb4d01 main: avoid Path(Path(...)) calls, they're slow 2021-10-01 15:30:03 +03:00
Ran Benita 16e5fbe371 config: optimize PytestPluginManager._getconftestmodules
Now that it's no longer using `@lru_cache`, use another check to avoid
re-computation. Although `@lru_cache` is faster than the full function
call + checks, this approach also has the advantage that the caching
works for more than 128 entries.
2021-10-01 15:25:28 +03:00
Ran Benita 614f5394b5 Avoid `@lru_cache` on methods
The problem with `@lru_cache` on methods is that it also captures `self`
and leaks it until the entry is evicted (if ever).
2021-10-01 14:41:14 +03:00
Ran Benita 1f938e3ef5 compat: replace REGEX_TYPE with typing.Pattern
Since Python 3.7, there is `re.Pattern` for this, but since we need to
support Python 3.6, can use `typing.Pattern` which works as well.
2021-10-01 14:00:15 +03:00
Brian Okken 6d6cfd839a Add a `deselected` parameter to `assert_outcomes()` 2021-09-29 07:22:53 -07:00
Bruno Oliveira 7f5e49e70b Fix formatting 2021-09-27 22:51:08 -03:00
pre-commit-ci[bot] 56fda99fa1 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-09-27 19:47:18 +00:00
Florian Bruhin 112204cf8d
Fix non-sensical error message (#9077)
* Fix non-sensical error message

Introduced in 12de92cd2b / #7698

* Add a test

* Put the unit back into unittest

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-09-24 06:15:53 +02:00
Simon K 740abd9684
#9062 - Allow `--stepwise-skip` to implicitly enable `--stepwise` (#9064)
* #9062 - Allow `--stepwise-skip` to implicitly enable `--stepwise`

* Update changelog/9062.improvement.rst

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-08-30 19:24:14 +01:00
Kale Kundert af42e7154a
Prevent approx from being used without a comparison (#9061)
Some of the top search-engine hits for pytest.approx use the function without actually comparing it to anything.

This PR will cause these tests to fail by implementing approx.__bool__() to raise an AssertionError that briefly explains how to correctly use approx.
2021-08-30 18:19:31 +00:00
Éloi Rivard 7770dacb8d pygments themes are customizable 2021-08-13 19:15:01 +02:00
Terje Runde 2439729413
logging: Make it possible to add cli colors to custom log levels
Closes #8803
PR #8804

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: Terje Runde <terje.runde@flir.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-08-09 13:48:47 +00:00
Ran Benita 25c65616f4 mark/expression: allow backslash characters in identifiers
Fixes #8983.
2021-08-08 11:56:17 +03:00
Simon K bacc8498e9
`pytest_assertion_pass` is no longer considered `experimental` (#8967)
* `pytest_assertion_pass` is no longer considered `experimental`

* adding changelog
2021-08-03 14:31:18 +01:00
Bruno Oliveira a83b359cf0
Refactor internal scope handling by introducing Scope enum
PR #8913
2021-08-01 06:11:56 -03:00
Simon K ef5d81ad5c
add `assert_outcomes(warnings=)` functionality to `RunResult`
* expose `warnings=` to pytester `assert_outcomes()`

* fix test fallout from adding warnings= to assert_outcomes()

* #closes 8593 - Improve test and add a `changelog` entry for the change
2021-07-31 15:25:10 +01:00
Simon K c27db3bd8e
Deprecate pytest_cmdline_preparse
Close #8592 

PR #8956
2021-07-31 10:53:43 -03:00
symonk 1b9ba65b3f typeshed `os.PathLike` is now `@runtime_checkable`, remove mypy ignore 2021-07-31 14:00:36 +01:00
Ran Benita 6247a95601
Merge pull request #8920 from bluetech/stabilize-store
Rename Store to Stash and make it public
2021-07-31 10:32:30 +03:00
Simon K d5c62d0326
Making `--debug` more configurable for the pytest user (#8955)
Close #8954
2021-07-30 17:37:38 -03:00
Simon K 6d6bc97231
#7124: Fix `--doctest-modules` crashing when `__main__.py` is present (#8949)
* Fix ``--doctest-modules`` crashing when ``__main__.py`` is present
2021-07-27 22:50:26 +01:00
Simon K 1d848314d0
some small quality of life changes (#8454)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-07-26 07:48:15 -03:00
Ran Benita 2aaea20cb2 Use {node,config}.stash instead of ._store
Use the public name. The `_store` name is only because some plugins
started using it anyway - will be removed at some point.
2021-07-24 17:40:08 +03:00
Ran Benita c6bdeb8491 stash: make Stash and StashKey public
It's had enough time to bake - let's allow external plugins to use it.
2021-07-24 17:40:08 +03:00
Ran Benita 5f39e31736 stash: implement __len__
Part of the MutableMapping abc (though we can't actually implement
that).
2021-07-18 15:32:52 +03:00
Ran Benita 5470d33e82 store: rename Store to Stash
The name "stash" is a bit more distinguishable and more evocative of the
intended usage.
2021-07-18 15:21:27 +03:00
Naveen-Pratap febb978651
Update error message for module level skip to include 'allow_module_level' (#8906)
Co-authored-by: Naveen <NaveenPr1@microland.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-07-14 14:27:26 +00:00
Bruno Oliveira 69356d20cf
Merge pull request #8903 from nicoddemus/remove-fspath-deprecation
Revert fspath deprecation
2021-07-14 09:32:48 -03:00
Bruno Oliveira 828fde1156
Merge pull request #8858 from The-Compiler/update-doc-urls 2021-07-14 09:28:46 -03:00
Bruno Oliveira 2c4c57e135 Revert fspath deprecation
It is not clear yet how we should proceed with this deprecation
because `pytest.Item.reportinfo` is public API and returns a `py.path` object,
and is not clear how plugins and our examples should handle that.

Reverting just the deprecation aspect of #8251 so we can get a 7.0.0 release out.

We will reintroduce the deprecation later once we have a clear path moving forward with replacing `reportinfo`.

Closes #8445
Closes #8821
2021-07-13 08:24:39 -03:00
Graeme Smecher 5c04674e96 Generate useful parameterization IDs for complex() numbers. 2021-07-12 12:27:24 -07:00
Anthony Sottile 5d8392cb68
Merge pull request #8874 from adamjstewart/monkeypatch/setenv
Docs: monkeypatch.setenv does not accept bool
2021-07-09 11:38:25 -04:00
Adam J. Stewart 17f1a0af8e
Fix in more places, use default 2021-07-08 12:43:10 -05:00
Adam J. Stewart 3989a9bb05
Docs: monkeypatch.setenv does not accept bool 2021-07-08 12:21:30 -05:00
Taneli Hukkinen e1a4b4edd2 Convert `TOMLDecodeError` to `UsageError` 2021-07-06 13:10:44 +03:00
pre-commit-ci[bot] 51f645e567 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-07-06 07:18:57 +00:00
Florian Bruhin 953fdabaf0 Adjust doc links for new scheme
Closes #8831
2021-07-06 09:11:35 +02:00