Commit Graph

13043 Commits

Author SHA1 Message Date
Sorin Sbarnea 1df2471f17
Make min duration configurable for slowest tests (#7667)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-09-05 09:18:29 -03:00
Bruno Oliveira 54f7a87ea8
Merge pull request #7714 from bluetech/doc-prefer-public
doc: prefer to reference by public name when possible
2020-09-04 20:39:03 -03:00
Bruno Oliveira db12d79c2a
Merge pull request #7713 from bluetech/doc-one-pm
doc/reference: include PluginManager in PytestPluginManager and remove it
2020-09-04 20:38:20 -03:00
Bruno Oliveira 44fc0192bc
Merge pull request #7719 from nicoddemus/fix-release-script
Use tox to execute release script
2020-09-04 18:45:29 -03:00
Bruno Oliveira 5371be4cf6 Use tox to execute release script
The release-on-comment script is always executed on *master*, so we should
execute the `release.py` script using tox to ensure we create the
right environment.

Also fixed errors in the error handling code.
2020-09-04 18:35:54 -03:00
Ran Benita 0ca2327069 doc: prefer to reference by public name when possible
When a name is exported from `pytest`, prefer to refer to it by that
rather than its `_pytest` import path. It is shorter and more
appropriate in user-facing documentation (although that's not really
visible).

Our plan is to expose more names for typing purposes, in which can this
could be more comprehensive.
2020-09-04 20:46:15 +03:00
Ran Benita 48a8c373a0 doc/reference: include PluginManager in PytestPluginManager and remove it
Before, `PluginManager` was a copy of the pluggy doc, and
`PytestPluginManager` was documented separately.

pytest users only really need to know about `PytestPluginManager`, so
instead of splitting have the `PytestPluginManager` documentation
include all of `PluginManager` members and remove `PluginManager` from
the reference (it is still shown as the base class).
2020-09-04 20:14:39 +03:00
Ran Benita 885d969484
Merge pull request #7685 from bluetech/py-to-pathlib-2
config: start migrating Config.{rootdir,inifile} from py.path.local to pathlib
2020-09-04 18:42:52 +03:00
Bruno Oliveira 0d0b798663
Merge pull request #7708 from nicoddemus/repr-line-7707
Fix handle of exceptions in ReprEntry with tb=line
2020-09-04 12:06:11 -03:00
Ran Benita 62e249a1f9 Replace some usages of config.{rootdir,inifile} with config.{rootpath,inipath} 2020-09-04 18:05:42 +03:00
Ran Benita a346028006 config: add Config.{rootpath,inipath}, turn Config.{rootdir,inifile} to properties 2020-09-04 18:04:25 +03:00
Ran Benita 3085c99e47 config: small doc improvements 2020-09-04 18:04:25 +03:00
Bruno Oliveira 19e99ab413
Integrate warnings filtering directly into Config (#7700)
Warnings are a central part of Python, so much that Python itself has
command-line and environtment variables to handle warnings.

By moving the concept of warning handling into Config, it becomes natural to
filter warnings issued as early as possible, even before the "_pytest.warnings"
plugin is given a chance to spring into action. This also avoids the weird
coupling between config and the warnings plugin that was required before.

Fix #6681
Fix #2891
Fix #7620
Fix #7626
Close #7649

Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-09-04 11:57:15 -03:00
Bruno Oliveira 9f672c85c5 Fix handle of exceptions in ReprEntry with tb=line
Fix #7707
2020-09-03 07:44:45 -03:00
Anthony Sottile 91dbdb6093
Merge pull request #7698 from bluetech/rm-scopedproperty
fixture: remove `@scopeproperty`
2020-08-28 17:26:10 -07:00
Bruno Oliveira 877c62166a
Merge pull request #7699 from bluetech/optimize-makeitem
python: small optimization in PyCollector.collect()
2020-08-28 09:53:00 -03:00
Bruno Oliveira 21aa6c42b7
Merge pull request #7697 from nicoddemus/file-docs 2020-08-28 09:52:02 -03:00
Bruno Oliveira ceea6000ba Add missing File reference to the docs
As related in #7696
2020-08-28 08:49:22 -03:00
Ran Benita 12de92cd2b fixture: remove `@scopeproperty`
I think the straight code is easier to understand.
2020-08-28 10:02:02 +03:00
Ran Benita daca174c98 python: small optimization in PyCollector.collect()
Inline `_makeitem()` so that `self.ihook` (which is moderately
expensive) can be called only once.

Note: the removed test "test_makeitem_non_underscore" comes from an old
behavior of skipping names that start with `_` which has since been
generalized, making the test no longer relevant.
2020-08-27 10:18:37 +03:00
Ran Benita 2fcf763d7e
Merge pull request #7671 from bluetech/ignored-names
RFC: python: skip work pytest_pycollect_makeitem work on certain names
2020-08-27 10:03:09 +03:00
Ran Benita 98891a5947 python: skip pytest_pycollect_makeitem work on certain names
When a Python object (module/class/instance) is collected, for each name
in `obj.__dict__` (and up its MRO) the pytest_pycollect_makeitem hook is
called for potentially creating a node for it.

These Python objects have a bunch of builtin attributes that are
extremely unlikely to be collected. But due to their pervasiveness,
dispatching the hook for them ends up being mildly expensive and also
pollutes PYTEST_DEBUG=1 output and such.

Let's just ignore these attributes.

On the pandas test suite commit 04e9e0afd476b1b8bed930e47bf60e,
collect only, irrelevant lines snipped, about 5% improvement:

Before:

```
         51195095 function calls (48844352 primitive calls) in 39.089 seconds

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
226602/54    0.145    0.000   38.940    0.721 manager.py:90(_hookexec)
    72227    0.285    0.000   20.146    0.000 python.py:424(_makeitem)
    72227    0.171    0.000   16.678    0.000 python.py:218(pytest_pycollect_makeitem)
```

After:

```
          48410921 function calls (46240870 primitive calls) in 36.950 seconds

    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
 181429/54    0.113    0.000   36.777    0.681 manager.py:90(_hookexec)
     27054    0.130    0.000   17.755    0.001 python.py:465(_makeitem)
     27054    0.121    0.000   16.219    0.001 python.py:218(pytest_pycollect_makeitem)
```
2020-08-26 17:43:57 +03:00
Bruno Oliveira 8730a7bb14
Merge pull request #7687 from bluetech/idval-notset
python: fix empty parametrize() leading to "NotSetType.token" id
2020-08-25 19:48:26 -03:00
Ran Benita a267a622eb python: fix empty parametrize() leading to "NotSetType.token" id
In ff8b7884e8 NOTSET was changed to a
singleton enum, which ended up unexpectedly triggering a code path in ID
generation which checks for `isinstance(Enum)`.

Add an explicit case for it, which is not too bad anyway.
2020-08-25 22:01:43 +03:00
Florian Bruhin 00996adeb8
Update talks/trainings page (#7661)
* Update talks/trainings page

- Remove past webinar
- Add new open training
- Add some talks/webinars by Oliver Bestwalter and by me
- Remove some stale link targets

* Move sidebar to index
2020-08-25 17:02:33 +02:00
Ran Benita ff41e7ad5d
Merge pull request #7670 from bluetech/session-inline
Start simplifying collection code in Session
2020-08-25 10:28:07 +03:00
Ran Benita c1f975668e main: couple of code simplifications 2020-08-24 18:15:11 +03:00
Ran Benita 023f0510af main: move collection cache attributes to local variables in collect()
They are only used for the duration of this function.
2020-08-24 18:15:11 +03:00
Ran Benita c867452488 main: inline matchnodes() into collect()
Now all of the logic is in one place and may be simplified and
refactored in more sensible way.
2020-08-24 18:15:11 +03:00
Ran Benita d0e8b71404 main: inline _collect() into collect()
This removes an unhelpful level of indirection and enables some upcoming
upcoming simplifications.
2020-08-24 18:15:11 +03:00
Ran Benita eec13ba57e main: get rid of NoMatch
Things are easier to understand without the weird exception.
2020-08-24 18:15:11 +03:00
Ran Benita c4fd461617 main: better name for _collection_node_cache3
The weird name was due to f3967333a1, now
that I understand it a bit better can give it a more descriptive name.
2020-08-24 18:15:11 +03:00
Ran Benita c2256189ae main: make matchnodes non-recursive
It's a little more sane this way.
2020-08-24 18:15:11 +03:00
Ran Benita 841521fedb main: only perform one recursive matchnodes call per node 2020-08-24 18:15:11 +03:00
Ran Benita 0c6b2f39b2 main: move NoMatch raising to _collect()
This is a more sensible interface for matchnodes.

This also fixes a sort-of bug where a recursive call to matchnodes
raises NoMatch which would terminate the entire tree, even if other
branches may find a match. Though I don't think it's actually possible.
2020-08-24 18:15:11 +03:00
Ran Benita a2c919d350 main: refactor a bit to reduce indentation 2020-08-24 18:15:11 +03:00
Ran Benita adaec2da90 main: remove impossible condition in matchnodes
Already covered in a condition above.
2020-08-24 18:15:11 +03:00
Ran Benita 1b2de81404 main: remove unneeded condition in matchnodes
The end result in the `else` branch is the same, but flows naturally.
2020-08-24 18:15:11 +03:00
Ran Benita 5356a0979a main: small code simplification in matchnodes 2020-08-24 18:15:11 +03:00
Ran Benita 0b41b79dcb main: better solution to a type ignore 2020-08-24 18:15:11 +03:00
Ran Benita 57aca11d4a hookspec: type annotate parent argument to pytest_collect_file 2020-08-24 18:15:11 +03:00
Ran Benita 4b8e1a1771 Revert "Move common code between Session and Package to FSCollector"
This reverts commit f10ab021e2.

The commit was good in that it removed a non-trivial amount of code
duplication. However it was done in the wrong layer (nodes.py) and split
up a major part of the collection (the filesystem traversal) to a
separate class making it harder to understand.

We should try to reduce the duplication, but in a more appropriate
manner.
2020-08-24 18:15:11 +03:00
Ran Benita 32edc4655c main: inline Session._matchnodes() into Session.matchnodes()
Similar to the previous commit, this makes things more straightforward.
2020-08-24 18:15:11 +03:00
Ran Benita d121d7c917 main: inline Session._perform_collect() into perform_collect()
It doesn't add much, mostly just an eye sore, particularly with the
overloads.
2020-08-24 18:15:10 +03:00
Ran Benita 1dad5c6433
Merge pull request #7669 from bluetech/collection-doc
hookspec: improve collection phase documentation a bit
2020-08-24 14:57:37 +03:00
Ran Benita 172b6e15c5 hookspec: improve collection phase documentation a bit
Make it a bit more accurate and use the same format that
pytest_runtest_protocol uses.
2020-08-24 13:00:09 +03:00
Ran Benita bb38ae9c52
Merge pull request #7651 from bluetech/capture-safe-disable
capture: fix disabled()/global_and_fixture_disabled() enabling capturing when it was disabled
2020-08-24 12:11:09 +03:00
Bruno Oliveira 6cf89338d3
Merge pull request #7677 from bluetech/flaky-no-tests-ran
testing: fix flaky test when executed slowly
2020-08-23 09:25:26 -03:00
Ran Benita b47b488e3d testing: fix flaky test when executed slowly
The 0-1 was a bit too optimistic: CI got "no tests ran in 3.98s".
2020-08-23 12:32:30 +03:00
Ran Benita 143e3ab846
Merge pull request #7673 from bluetech/logging-fix-handler-restore
logging: fix handler level restored incorrectly if caplog.set_level is called more than once
2020-08-23 12:06:09 +03:00