Commit Graph

13324 Commits

Author SHA1 Message Date
Tim Hoffmann afd53ede6f
Link mentioned functions instead of using literals (#8045) 2020-11-19 15:44:59 +01:00
Bruno Oliveira 329e66c22e
Merge pull request #8051 from The-Compiler/nose-fixup
Fix nose documentation
2020-11-19 10:04:59 -03:00
Florian Bruhin c6ac618baf Fix nose documentation
Follow-up to #8048 which seems to have been merged without the suggested changes.
2020-11-19 13:54:40 +01:00
Bruno Oliveira 42f9622a90
Merge pull request #8048 from mickeypash/patch-1
Add small section on migrating from nose to pytest.
2020-11-19 09:02:04 -03:00
mickeypash ce825ed16c Add small section on migrating from nose to pytest
The section currently features the nose2pytest tool with plans to expand
on some of the common gotchas when performing such migrations.
2020-11-19 08:50:11 -03:00
Petter Strandmark eda681af2b
Call Python 3.8 doClassCleanups (#8033) 2020-11-19 12:07:15 +02:00
Tim Hoffmann b7ba76653d
Prefix contextmanagers with module name in doc examples (#8044)
* Prefix contextmanagers with module name in doc examples

* Import pytest explicitly for doctests

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-11-19 12:06:24 +02:00
Ran Benita 30d89fd07e
Merge pull request #8039 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-html-3.0.0
build(deps): bump pytest-html from 2.1.1 to 3.0.0 in /testing/plugins_integration
2020-11-19 12:05:04 +02:00
Ran Benita 8ea8cdb36d
Merge pull request #8040 from symonk/remove-unused-var-in-pytester
stop assigning nextline if its potentially not used
2020-11-17 18:00:17 +02:00
symonk 3b677f79f4 stop assigning nextline if its potentially not used 2020-11-17 11:30:09 +00:00
Ran Benita 537215a16c
Merge pull request #7987 from bluetech/ci-deprecated
ci: fix deprecation message & couple updates
2020-11-16 23:29:35 +02:00
Ran Benita c2f949d68e
Merge pull request #8013 from itsmegarvi/master
#7942 migrate from tempdir to pytester
2020-11-16 19:44:43 +02:00
Garvit Shubham 6fe9d2fb9f testing: convert test_{conftest,recwarn,tmpdir} to pytester 2020-11-16 19:22:57 +02:00
dependabot[bot] 3a899ced76
build(deps): bump pytest-html in /testing/plugins_integration
Bumps [pytest-html](https://github.com/pytest-dev/pytest-html) from 2.1.1 to 3.0.0.
- [Release notes](https://github.com/pytest-dev/pytest-html/releases)
- [Changelog](https://github.com/pytest-dev/pytest-html/blob/master/CHANGES.rst)
- [Commits](https://github.com/pytest-dev/pytest-html/compare/v2.1.1...v3.0.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-16 03:15:18 +00:00
Ran Benita 825b81ba52
Merge pull request #8014 from bluetech/pyc-pep552
assertion/rewrite: write pyc's according to PEP-552 on Python>=3.7
2020-11-14 23:38:45 +02:00
Ran Benita 1d532da49e assertion/rewrite: write pyc's according to PEP-552 on Python>=3.7
Python 3.7 changes the pyc format by adding a flags byte. Even though it
is not necessary for us to match it, it is nice to be able to read pyc
files we emit for debugging the rewriter.

Update our custom pyc files to use that format. We write flags==0
meaning we still use the mtime+size format rather the newer hash format.
2020-11-14 23:20:12 +02:00
Ran Benita 767cbeb086
Merge pull request #8002 from mcsitter/add-pythonenv-gitignore
Add pythonenv* to gitignore
2020-11-13 23:14:23 +02:00
Maximilian Cosmo Sitter 25e4dd0d2c Fix scope to accomodate requested changes 2020-11-13 20:00:44 +00:00
Ran Benita c14f498622
Merge pull request #7908 from bluetech/post-release-tag
RELEASING: make sure we have an accurate version in a commit in master
2020-11-13 12:57:53 +02:00
Ran Benita f6b682ad49 RELEASING: start new dev cycle by tagging MAJOR.{MINOR+1}.0.dev0 in master
This is needed so setuptools-scm in master shows an accurate version.
In particular, higher than the stable branch.
2020-11-13 12:38:58 +02:00
Ran Benita 701ff1f5a1 ci: only deploy to PyPI on X.Y.Z{,rcN} tags
We want to reserve other tags for our own purposes without it creating a
release.
2020-11-13 12:38:30 +02:00
Ran Benita f1e6fdcddb Export types of builtin fixture for type annotations
In order to allow users to type annotate fixtures they request, the
types need to be imported from the `pytest` namespace. They are/were
always available to import from the `_pytest` namespace, but that is
not guaranteed to be stable.

These types are only exported for the purpose of typing. Specifically,
the following are *not* public:

- Construction (`__init__`)
- Subclassing
- staticmethods and classmethods

We try to combat them being used anyway by:

- Marking the classes as `@final` when possible (already done).

- Not documenting private stuff in the API Reference.

- Using `_`-prefixed names or marking as `:meta private:` for private
  stuff.

- Adding a keyword-only `_ispytest=False` to private constructors,
  warning if False, and changing pytest itself to pass True. In the
  future it will (hopefully) become a hard error.

Hopefully that will be enough.
2020-11-13 11:25:09 +02:00
Ran Benita b050578882 pytester: split asserts to a separate plugin, don't rewrite pytester itself
An upcoming commit wants to import from `_pytest.pytester` in the public
`pytest` module. This means that `_pytest.pytester` would start to get
imported during import time, which it hasn't up to now -- it was
imported by the plugin loader (if requested). When a plugin is loaded,
it is subjected to assertion rewriting, but only if the module isn't
imported yet, it issues a warning "Module already imported so cannot be
rewritten" and skips the rewriting. So we'd end up with the pytester
plugin not being rewritten, but it wants to be.

Absent better ideas, the solution here is to split the pytester
assertions to their own plugin (which will always only be imported by
the plugin loader) and exclude pytester itself from plugin rewriting.
2020-11-13 11:25:09 +02:00
Ran Benita 66311ff702
Merge pull request #8022 from bluetech/doctest-init
main: fix only one doctest collected on pytest --doctest-modules __init__.py
2020-11-13 10:46:46 +02:00
Ran Benita ea3c0aa245
Merge pull request #8019 from JosiasAurel/mypytester-change-01
Migrate from testdir to pytester
2020-11-13 10:36:03 +02:00
Bruno Oliveira 843bca8c0c
Merge pull request #8025 from adamchainz/issue_8023_norecursedirs
Add 'node_modules' to norecursedirs
2020-11-12 07:36:38 -03:00
Josias Aurel fa148eadfe
Update testing/test_faulthandler.py
Co-authored-by: Sanket Duthade <duthades@gmail.com>
2020-11-11 18:35:06 +01:00
Bruno Oliveira ff9e35243e
Merge pull request #7928 from graingert/feature-request-template 2020-11-11 09:20:00 -03:00
Josias Aurel 06a597db14
Add type annotations 2020-11-11 05:02:32 +01:00
Josias Aurel 1ed8159c7d
Update testing/test_faulthandler.py
Co-authored-by: Sanket Duthade <duthades@gmail.com>
2020-11-11 04:45:57 +01:00
Josias Aurel 8320c07134
Update testing/test_faulthandler.py
Co-authored-by: Sanket Duthade <duthades@gmail.com>
2020-11-11 04:45:42 +01:00
Adam Johnson 39b2706f6a Add 'node_modules' to norecursedirs
Fixes #8023.
2020-11-11 01:52:18 +00:00
Ran Benita 265cc2cfec main: fix only one doctest collected on pytest --doctest-modules __init__.py
When --doctest-modules is used, an `__init__.py` file is not a `Package`
but a `DoctestModule`, but some collection code assumed that
`__init__.py` implies a `Package`. That code caused only a single test
to be collected in the scenario in the subject.

Tighten up this check to explicitly check for `Package`. There are
better solutions, but for another time.

Report & test by Nick Gates <nickgatzgates@gmail.com>.
2020-11-10 22:50:46 +02:00
Josias Aurel 043ed55056
Migrate from testdir to pytester 2020-11-09 18:07:34 +01:00
Ran Benita e986d84466
Merge pull request #8006 from bluetech/export-MonkeyPatch
Export MonkeyPatch as pytest.MonkeyPatch
2020-11-09 11:45:38 +02:00
Ran Benita 6f13d1b03b Export MonkeyPatch as pytest.MonkeyPatch
We want to export `pytest.MonkeyPatch` for the purpose of
type-annotating the `monkeypatch` fixture. For other fixtures we export
in this way, we also make direct construction of them (e.g.
`MonkeyPatch()`) private. But unlike the others, `MonkeyPatch` is also
widely used directly already, mostly because the `monkeypatch` fixture
only works in `function` scope (issue #363), but also in other cases. So
making it private will be annoying and we don't offer a decent
replacement yet.

So, let's just make direct construction public & documented.
2020-11-09 11:28:15 +02:00
Ran Benita 7aa5e49fc4
Merge pull request #8012 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.1.3
build(deps): bump django from 3.1.2 to 3.1.3 in /testing/plugins_integration
2020-11-09 11:26:35 +02:00
dependabot[bot] 02d4b3d75f
build(deps): bump django in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.1.2...3.1.3)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-09 03:17:35 +00:00
Bruno Oliveira b2e7b9df9e
Merge pull request #8010 from nicoddemus/pluralize 2020-11-08 13:31:27 -03:00
Bruno Oliveira c7f8ad17f5 Rename _make_plural to pluralize
A bit shorter and a better name, IMHO.
2020-11-08 12:42:52 -03:00
Hugo Martins 5b2e5e8a40
Improve summary stats when using '--collect-only' (#7875)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-11-08 11:45:10 -03:00
Ran Benita 29f2f4e854
Merge pull request #8005 from bluetech/pytest-import
Stop importing `pytest` to avoid upcoming import cycles
2020-11-08 14:15:19 +02:00
Bruno Oliveira 10a3a49bd6
Merge pull request #8007 from bluetech/dont-ignore-already-imported
testing: don't ignore "Module already imported so cannot be rewritten" warning
2020-11-07 22:46:15 -03:00
frankgerhardt 9bc633064b
Capitalize headlines (#8008) 2020-11-07 22:44:04 -03:00
Ran Benita 361f9e20c3 testing: don't ignore "Module already imported so cannot be rewritten" warning
The test suite passes without it being ignored. The absence of this
warning cost me some head-scratching time, so enable it again.
2020-11-07 18:14:21 +02:00
Ran Benita 1cbb0c3554 Stop importing `pytest` to avoid upcoming import cycles
Don't import `pytest` from within some `_pytest` modules since an
upcoming commit will import from them into `pytest`.

It would have been nice not to have to do it, so that internal plugins
look more like external plugins, but with the existing layout this seems
unavoidable.
2020-11-07 18:08:30 +02:00
Ran Benita c784c142a4
Merge pull request #7988 from bluetech/deprecate-yield-fixture
fixtures: deprecate pytest.yield_fixture()
2020-11-07 18:07:00 +02:00
Ran Benita 4c0513bc18 fixtures: deprecate pytest.yield_fixture() 2020-11-07 17:06:40 +02:00
Sanket Duthade 3bcd316f07
test_collection.py migrate from testdir to Pytester (#8003) 2020-11-07 16:56:00 +02:00
Garvit Shubham 6a5037a25b
#7942 test_setupplan.py migrate from testdir to Pytester (#8004)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-11-07 09:29:45 -03:00