Compare commits

...

994 Commits
5.2.3 ... 5.4.3

Author SHA1 Message Date
pytest bot
b322004047 Preparing release version 5.4.3 2020-06-02 15:22:35 +00:00
Bruno Oliveira
2d795dc07b Merge pull request #7298 from nicoddemus/backport-6755
[5.4.x] Fix removal of very long paths on Windows (#6755)
2020-06-02 09:48:49 -03:00
Ran Benita
2d6b846978 Merge pull request #7299 from nicoddemus/backport-7294
[5.4.x] Merge pull request #7294 from nicoddemus/codecov-adjustments
2020-06-02 15:29:26 +03:00
Bruno Oliveira
703d0f50d8 Merge pull request #7294 from nicoddemus/codecov-adjustments 2020-06-02 09:02:48 -03:00
Tor Colvin
56e6482405 Fix removal of very long paths on Windows (#6755)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-06-02 08:58:01 -03:00
Bruno Oliveira
589176e9fe Merge pull request #7285 from nicoddemus/backport-7220
[5.4] Merge pull request #7220 from nicoddemus/issue-6428
2020-05-30 21:00:53 -03:00
Bruno Oliveira
3734a27733 [5.4] Do not call TestCase.tearDown for skipped tests (#7236) (#7283)
[5.4] Do not call TestCase.tearDown for skipped tests (#7236)
2020-05-30 21:00:08 -03:00
Bruno Oliveira
e1a21e46b0 Merge pull request #7220 from nicoddemus/issue-6428 2020-05-30 20:14:57 -03:00
Bruno Oliveira
551400e8d6 Do not call TestCase.tearDown for skipped tests (#7236)
Fix #7215
2020-05-30 14:34:45 -03:00
Anthony Sottile
b7b729298c Merge pull request #7271 from asottile/backport-7257
[5.4.x] Merge pull request #7257 from DahlitzFlorian/fix-issue-6956
2020-05-27 15:02:10 -07:00
Anthony Sottile
21ca38b932 Merge pull request #7257 from DahlitzFlorian/fix-issue-6956
Prevent pytest from printing ConftestImportFailure traceback

(cherry picked from commit b3db440d4c)
2020-05-27 13:52:10 -07:00
Anthony Sottile
565f4cb4ad Merge pull request #7248 from asottile/backport-7244
[5.4.x] Merge pull request #7244 from DahlitzFlorian/fix-issue-7150
2020-05-23 12:45:35 -07:00
Anthony Sottile
af6548a4e7 Merge pull request #7244 from DahlitzFlorian/fix-issue-7150
Prevent hiding underlying exception when ConfTestImportFailure is raised

(cherry picked from commit 45f53266e6)
2020-05-23 12:13:34 -07:00
Bruno Oliveira
2fb2962df4 Merge pull request #7193 from pytest-dev/release-5.4.2 2020-05-08 09:01:11 -03:00
pytest bot
f838c7b7eb Preparing release version 5.4.2 2020-05-08 11:14:08 +00:00
Bruno Oliveira
25b53c4196 Merge pull request #7188 from asottile/backport_7179 2020-05-08 06:58:08 -03:00
Bruno Oliveira
fc27171d57 Merge pull request #7189 from asottile/backport-7186 2020-05-08 06:57:25 -03:00
Anthony Sottile
d18e426b24 Merge pull request #7186 from asottile/is_setup_py_encoding_agnostic
Fix _is_setup_py for files encoded differently than locale
2020-05-07 14:02:00 -07:00
Bruno Oliveira
e83fa48dd1 Merge pull request #7179 from asottile/py39 2020-05-07 13:57:10 -07:00
Bruno Oliveira
c53d52c3f2 Merge pull request #7174 from nicoddemus/backport-7168 2020-05-06 18:24:43 -03:00
Bruno Oliveira
3886c6d735 Merge pull request #7168 from nicoddemus/saferepr-getattr-fail-7145 2020-05-06 17:59:42 -03:00
Bruno Oliveira
80936b6762 Merge pull request #7156 from nicoddemus/backport-7151 2020-05-02 16:01:15 -03:00
Bruno Oliveira
5ca08e9b8a Merge pull request #7151 from nicoddemus/unittest-cleanup-6947 2020-05-02 15:44:39 -03:00
Bruno Oliveira
ba2c49e71e Merge pull request #7149 from nicoddemus/backport-7144 2020-05-01 17:08:55 -03:00
Bruno Oliveira
da615a4fbe Merge pull request #7144 from nicoddemus/async-testcase-7110 2020-05-01 16:45:01 -03:00
Bruno Oliveira
32562881d4 Merge pull request #7146 from nicoddemus/backport-7143 2020-05-01 13:31:24 -03:00
Bruno Oliveira
2a0bbfe63f Merge pull request #7143 from nicoddemus/file-from-parent 2020-05-01 13:08:42 -03:00
Ronny Pfannschmidt
9aed656ec7 Merge pull request #7066 from RonnyPfannschmidt/backport-6992-restore-tmpdir-indirection
backport #6992 to 5.4.x - restores tmpdir indirection
2020-04-10 13:11:17 +02:00
Ronny Pfannschmidt
a600e7a2a4 Merge pull request #7068 from RonnyPfannschmidt/backport-6927-run-async-unittest
backport #6927: run async testcase methods
2020-04-10 13:11:05 +02:00
Ronny Pfannschmidt
57a95b3a2c Merge pull request #7067 from RonnyPfannschmidt/backport-6986-terminalreporter.writer
backport #6986: writable TerminalWriter.writer for deprecation
2020-04-10 11:25:42 +02:00
Ronny Pfannschmidt
f5e430fd8f Merge pull request #6927 from RonnyPfannschmidt/fix-6924-run-async-stdlib-unittests
running stdlib asyncio unittests again
2020-04-10 08:16:58 +02:00
Ronny Pfannschmidt
38a4c7e56c Merge pull request #6986 from RonnyPfannschmidt/fix-6951-tw.writer-writable
fix #6951: allow to write TerminalReporter.writer
2020-04-10 08:12:34 +02:00
Ronny Pfannschmidt
40f02d72b0 Merge pull request #6992 from pytest-dev/revert-6767-tmpdir-cleanup-upstream
Revert "tmpdir: clean up indirection via config for factories"
2020-04-10 08:07:53 +02:00
Daniel Hahler
554f600fb4 Fix TerminalRepr instances to be hashable (#6988) (#7006)
pytest-xdist assumes `ExceptionChainRepr` is hashable.

Fixes https://github.com/pytest-dev/pytest/issues/6925.
Fixes https://github.com/pytest-dev/pytest-xdist/issues/515.

(cherry picked from commit 20f6331afd)
2020-04-03 10:59:23 +02:00
Ran Benita
e3a3c90d94 [5.4.x] Fix crash when printing while capsysbinary is active (#7002)
Backport of 1fda861190 from master.
2020-04-02 14:31:32 +03:00
Ran Benita
f7327759e8 ci: twisted and oldattrs tox envs are now incompatible, don't run them together
twisted started to use `attr.s(eq)` argument which was added recently,
so it fails with oldattrs. One of the CI jobs ran twisted and oldattrs
together, so it started to fail.

Move the twisted code to be covered by another job, and remove it from
the job with the oldattrs.

(cherry picked from commit 2cc3227f6a)
2020-03-31 09:48:11 +02:00
Bruno Oliveira
ee1950af77 Merge pull request #6918 from pytest-dev/release-5.4.1
Prepare release 5.4.1
2020-03-13 11:11:05 -03:00
pytest bot
3d0f3baa2b Preparing release version 5.4.1 2020-03-13 13:34:24 +00:00
Bruno Oliveira
8da758b93a Merge pull request #6917 from nicoddemus/backport-6916
[Backport] Skip link checks when doing releases through the bot (#6916)
2020-03-13 10:34:10 -03:00
Bruno Oliveira
59e5d1bfbf Merge pull request #6916 from nicoddemus/no-link-checks
Skip link checks when doing releases through the bot
2020-03-13 10:32:25 -03:00
Bruno Oliveira
b9e2cd0a81 Merge pull request #6914 from nicoddemus/revert-6330
Revert "[parametrize] enforce explicit argnames declaration (#6330)"
2020-03-13 10:18:06 -03:00
Bruno Oliveira
a84fcbf5b2 Revert "[parametrize] enforce explicit argnames declaration (#6330)"
This reverts commit 9e262038c8.

Fix #6909
2020-03-13 09:59:53 -03:00
Bruno Oliveira
59c1bfada7 Merge pull request #6913 from nicoddemus/backport-6910
[Backport #6910] Handle unknown stats in pytest_report_teststatus hook
2020-03-13 09:48:11 -03:00
Bruno Oliveira
3267f64724 Merge pull request #6910 from nicoddemus/resultlog-logreport
Handle unknown stats in pytest_report_teststatus hook
2020-03-13 09:30:14 -03:00
pytest bot
c9fd1bdbd6 Preparing release version 5.4.0 2020-03-12 14:14:35 +00:00
Ronny Pfannschmidt
93aa988e01 Merge pull request #6901 from RonnyPfannschmidt/regendoc-fix-simple
run and fix tox -e regen to prepare 5.4
2020-03-12 15:09:10 +01:00
Ran Benita
7996724f23 Merge pull request #6902 from RoyalTS/filterwarnings-docfix
Minor docfix
2020-03-12 12:39:33 +02:00
Tobias Schmidt
90ee8a7599 docfix 2020-03-12 09:38:00 +01:00
Ronny Pfannschmidt
378a75ddf6 run and fix tox -e regen to prepare 5.4
* no longer trigger deprecation warnings when looking up fixtures
* fix missed imports in a test example
2020-03-11 22:25:51 +01:00
Bruno Oliveira
e1b3a68462 Merge pull request #6896 from nicoddemus/release-trigger
Fix bot trigger event
2020-03-11 10:04:41 -03:00
Ronny Pfannschmidt
fb7dbc9fa3 Merge pull request #6893 from RonnyPfannschmidt/url-fixes
fix urls that fail linkcheck
2020-03-11 14:02:46 +01:00
Bruno Oliveira
a0ea300e96 Fix bot trigger event
Issue events don't contain a 'comment' entry:
https://developer.github.com/v3/issues/events/#response-2

Issue comments also contain the original issue body:
https://developer.github.com/v3/activity/events/types/#issuecommentevent

That's why it was triggering even for comments on the issue.

Also changed to startsWith because there's no need to support
the command anywhere in the body IMO.

Fix #6895
2020-03-11 09:54:56 -03:00
Ronny Pfannschmidt
09b289e286 fix mozilla qa project link 2020-03-11 11:10:33 +01:00
Ronny Pfannschmidt
694dbe5bd4 fix pydanny.com url to the one with ssl set up 2020-03-11 10:52:16 +01:00
Ran Benita
4f8fff9cab Merge pull request #6868 from bluetech/simplify-exc
Simplify some exception handling code
2020-03-10 20:32:08 +02:00
Daniel Hahler
ac7ebfa22e doc: internal: fix MultiCapture.readouterr (#6878)
Remove wrong docstring: it might actually return bytes.
Replace it with a type annotation which is clear enough.
2020-03-08 12:38:21 +01:00
Daniel Hahler
db92cea14c black: --target-version py35 (#6872) 2020-03-08 01:24:31 +01:00
Daniel Hahler
bce1d40fb0 tests: harden test_reprcompare_notin, factor out callop (#6764)
* tests: assertion: factor out `callop`, typing

* tests: harden test_reprcompare_notin
2020-03-08 01:23:19 +01:00
Daniel Hahler
dc86fb6758 pre-commit run --all-files 2020-03-07 23:47:55 +01:00
Daniel Hahler
2df4f63149 Add config for black (target-version) 2020-03-07 23:47:55 +01:00
Daniel Hahler
e3cf4fc258 doc/en/Makefile: use Sphinx's make mode (#6873)
Syncs it from the output of current sphinx-quickstart.
2020-03-07 23:45:05 +01:00
Ran Benita
978b315861 Simplify some exception handling code
Mostly avoid unnecessary usage of sys.exc_info(). Since Python3,
exception objects themselves have all that's needed. They are also
easier to type.
2020-03-07 13:18:54 +02:00
Ran Benita
580edc13e7 Merge pull request #6867 from bluetech/inline-pyobjmixin
Inline PyobjContext
2020-03-07 11:58:38 +02:00
Ran Benita
1df593f978 Merge pull request #6865 from bluetech/more-config-store
Convert a couple of places to use config store
2020-03-06 15:49:01 +02:00
Ran Benita
b7f2e3d4f5 Inline PyobjContext
When it was introduced in 8adac2878f it
seems to have had some use, but now it doesn't.
2020-03-06 14:55:20 +02:00
Ran Benita
f011bc642c Store mark's evalcache in config's store instead of attribute
Part of moving away from ad-hoc attributes to using the config's store.
2020-03-06 11:42:20 +02:00
Ran Benita
b1d7a187f2 Add setdefault() method to Store
Can be useful in some cases.
2020-03-06 11:42:20 +02:00
Ran Benita
678d65f051 Store AssertionState in config's store instead of attribute
Part of moving away from ad-hoc attributes to using the config's store.
2020-03-06 11:27:01 +02:00
Daniel Hahler
fcd3fad03d Minor internal improvements to logging's log_level (#6849) 2020-03-06 03:12:57 +01:00
Daniel Hahler
9e8540f25f docs: remove doc/en/links.inc (#6853) 2020-03-06 03:11:24 +01:00
Bruno Oliveira
19bb2c6235 Merge pull request #6859 from nicoddemus/kw-mapping-attr-typing
Use attrs in KeywordMapping
2020-03-05 08:47:22 -03:00
Bruno Oliveira
bc8e52c3c2 Use attrs in KeywordMapping
Also added type hinting.
2020-03-05 08:33:20 -03:00
Bruno Oliveira
333bb0883a Merge pull request #6860 from pytest-dev/pytest_twisted_in_async_warning
Add pytest-twisted to list of async def handling plugins
2020-03-04 21:48:20 -03:00
Kyle Altendorf
dce2621710 Add pytest-twisted to list of async def handling plugins
https://github.com/pytest-dev/pytest-twisted/tree/v1.12#ensuredeferred

[pytest-twisted](https://github.com/pytest-dev/pytest-twisted) supports `async def` test functions and fixtures as well as `async def`/`yield` fixtures.
2020-03-04 17:42:08 -05:00
Daniel Hahler
acec0b688f Fix usage of pytester with doctests (#6802)
Use `request.node.name` instead of `request.function.__name__`:
`request.function` is `None` with `DoctestItem`s.
2020-03-04 05:33:50 +01:00
Daniel Hahler
197b7c3bce Add .gitblameignore (#6848) 2020-03-04 05:32:30 +01:00
Daniel Hahler
37d074efc8 Fix (internal) documentation for pytester's LineComp (#6850) 2020-03-04 05:25:32 +01:00
Ronny Pfannschmidt
a5a8d53dfe remove myself from the list of coc handlers (#6857) 2020-03-03 19:08:59 -03:00
Ronny Pfannschmidt
9fd71d6fe0 fix #571: deprecate pytest_collect_directory as ... (#6847)
Deprecate pytest_collect_directory

Fix #571

Co-authored-by: Daniel Hahler <github@thequod.de>
2020-03-03 18:58:14 -03:00
Daniel Hahler
b11bfa106c Use attrs with all Repr classes (#6739)
Co-authored-by: Ran Benita <ran234@gmail.com>
2020-03-03 21:53:28 +01:00
Daniel Hahler
bd7e33277b docs: remove tracking through Google Analytics (#6843)
This might not even be monitored by anyone, but if it is useful in
general should probably get replaced with a less controversial provider.
2020-03-03 01:35:14 +01:00
Daniel Hahler
ddc8edffbc logging: minor typing, rename function
`get_log_level_for_setting` reflects better what the function does, and
it does not require a (trivial) docstring.
2020-03-01 22:02:46 +01:00
Daniel Hahler
bdd22fdd52 logging: improve help for log_level 2020-03-01 22:02:46 +01:00
Ronny Pfannschmidt
194b52145b Merge pull request #6834 from RonnyPfannschmidt/fix-6833-summarize-warning-item-locations
summarize warning summaries if the number of locations is high
2020-03-01 20:21:36 +01:00
Bruno Oliveira
15e1dd0f87 Automate release by comment notifications (#6823)
* Automate release by comment notifications

* Only run if @pytestbot is mentioned
2020-03-01 14:46:35 -03:00
Ronny Pfannschmidt
23c43a37e0 summarize warning summaries if the number of locations is high 2020-03-01 14:08:15 +01:00
Bruno Oliveira
92767fec51 Merge pull request #6836 from bluetech/store
Add a typing-compatible mechanism for ad-hoc attributes on various objects
2020-03-01 09:30:10 -03:00
Ran Benita
5fc80d8bc3 Merge pull request #6844 from bluetech/asserthook-abc-loader
Mark AssertionRewritingHook as implementing importlib.abc.Loader
2020-02-29 23:21:11 +02:00
Ran Benita
2f60548e08 Mark AssertionRewritingHook as implementing importlib.abc.Loader
It implements the required methods. This is useful for typing but also a
nice indicator.
2020-02-29 16:55:56 +02:00
Daniel Hahler
f10ab021e2 Move _collectfile to FSCollector (#6830)
Previously this was implemented both on `Session` and `Package`, where
the extra code in `Package._collectfile` was not covered/used.

Ref: https://github.com/pytest-dev/pytest/pull/6830#issuecomment-592663236
2020-02-29 11:40:11 +01:00
Bruno Oliveira
ff7b5dbbde Merge pull request #6784 from nicoddemus/deprecate-terminal-writer
Deprecate TerminalReporter.writer
2020-02-28 21:07:02 -03:00
Daniel Hahler
4b53bbc0a9 docs: use doc/en/_build/html for html output (#6842)
This will use the same directory as `make -C doc/en` then, and reflects
the default location that Sphinx uses.
2020-02-29 00:47:30 +01:00
Daniel Hahler
769ffc32bf Add Read The Docs badge to README (#6841) 2020-02-29 00:29:56 +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
952cab2d85 Simplify test_rootdir_wrong_option_arg (#6812) 2020-02-28 18:38:07 +01:00
Ran Benita
d636fcd557 Add a typing-compatible mechanism for ad-hoc attributes on various objects
pytest has several instances where plugins set their own attributes on
objects they receive in hooks, like nodes and config. Since plugins are
detached from these object's definition by design, this causes a problem
for type checking because these attributes are not defined and mypy
complains.

Fix this by giving these objects a "store" which can be used by plugins
in a type-safe manner.

Currently this mechanism is private. We can consider exposing it at a
later point.
2020-02-28 14:34:44 +02:00
Daniel Hahler
f77d606d4e docs: generate index and add it to globaltoc sidebar (#6808) 2020-02-27 00:34:18 +01:00
Daniel Hahler
16c683dff9 Remove unused setns (#6804)
Last usage of it was removed in ba17363d7.
2020-02-26 15:35:14 +01:00
Daniel Hahler
2e48c32dea docs: fix reference to config.cache fixture (#6807) 2020-02-26 01:24:18 +01:00
Stefano Mazzucco
2451716746 Remove reference to old konira plugin from docs (#6819)
The pytest-konira plugin has not seen an update since 2011, moreover
the "project description" on PyPI points to a dubious website that
does not actually correspond to the project and instead redirects to
advertising content.
2020-02-26 01:19:40 +01:00
Daniel Hahler
6a7df7f031 test_assertion: harden/improve test_{text_diff,unicode} (#6806) 2020-02-24 15:19:08 +01:00
Daniel Hahler
ac3a42bafd doctest: strip newlines with unexpected exceptions (#6801) 2020-02-24 15:18:08 +01:00
Daniel Hahler
be23aeb989 Remove unused pytester.getdecoded (#6805)
Last usage was removed in 22dc47d9f.
2020-02-24 14:33:26 +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
9928c7794b minor: fix trace msg: s/loaded/loading (#6798) 2020-02-23 17:12:30 +01:00
Daniel Hahler
706ea86bba capture: factor out _get_multicapture (#6788)
Ref: https://github.com/pytest-dev/pytest/pull/6671#issuecomment-588408992
2020-02-22 23:39:20 +01:00
Daniel Hahler
1d5a0ef284 Fix pytest_ignore_collect hooks: do not return False (#6778)
It should only return `True` when something is to be ignored, not
`False` otherwise typically.

This caused e.g. bad interaction with the cacheprovider (before
https://github.com/pytest-dev/pytest/pull/6448).
2020-02-22 23:35:47 +01:00
Daniel Hahler
c8b4a1a471 Handle match with pytest.raises() (#6753)
Fixes https://github.com/pytest-dev/pytest/issues/6752.
2020-02-22 23:32:55 +01:00
Daniel Hahler
68fe0eb8f3 Minor cosmetic fixes (#6792) 2020-02-22 19:24:41 +01:00
Daniel Hahler
de854c6ee1 doc: pytest.raises: remove mention of removed message (#6793)
Follow-up to 13f7f27fd.
2020-02-22 19:24:00 +01:00
Daniel Hahler
04126feea7 doc: pytest.raises: link to python:try (#6794) 2020-02-22 19:23:35 +01:00
kpinc
eeebcd77dd doc: add list of fixtures to start of fixture chapter (#6696)
- Add list of fixtures to start of fixture chapter
- Add "fixture" cross ref type
2020-02-22 14:56:19 +01:00
Daniel Hahler
478a244f5e main: args must be a list, not tuple (#6791)
Passing in a tuple crashes in `_prepareconfig`:

        def test_invoke_with_tuple(self):
    >       pytest.main(("-h",))

    src/_pytest/config/__init__.py:82: in main
        config = _prepareconfig(args, plugins)
    src/_pytest/config/__init__.py:229: in _prepareconfig
        return pluginmanager.hook.pytest_cmdline_parse(
    …
    src/_pytest/helpconfig.py:98: in pytest_cmdline_parse
        config = outcome.get_result()  # type: Config
    src/_pytest/config/__init__.py:808: in pytest_cmdline_parse
        self.parse(args)
    src/_pytest/config/__init__.py:1017: in parse
        self._preparse(args, addopts=addopts)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

        def _preparse(self, args: List[str], addopts: bool = True) -> None:
            …
            if addopts:
                ini_addopts = self.getini("addopts")
                if ini_addopts:
    >               args[:] = self._validate_args(ini_addopts, "via addopts config") + args
    E               TypeError: can only concatenate list (not "tuple") to list

    addopts    = True
    args       = ('-h',)
    env_addopts = ''
    ini_addopts = ['-rfEX', …]

    src/_pytest/config/__init__.py:956: TypeError: can only concatenate list (not "tuple") to list

Might be worth handling (converting it to a list for example), but it
was documented to be a list to begin with when removing support for
strings (a7e401656).
2020-02-22 13:16:46 +01:00
Daniel Hahler
47ccd58fb4 Fix typo in doc with syspath_prepend 2020-02-22 13:15:17 +01:00
Daniel Hahler
2277817176 Fix grammar in changelog/6737.breaking.rst 2020-02-22 13:15:17 +01:00
Daniel Hahler
1baeefc2fd test_reprcompare_whitespaces: use callequal 2020-02-22 13:15:17 +01:00
Daniel Hahler
260f848c05 minor: remove outdated, superfluous comment 2020-02-22 13:15:17 +01:00
Bruno Oliveira
7c0d1cad40 Merge pull request #6790 from TWood67/master
Updated Dynamic Scopes Documentation
2020-02-21 16:47:22 -03:00
TWood67
b26e60c2da updated documentation
added a default value so a runtime exception does not occur
2020-02-21 11:45:24 -06:00
Daniel Hahler
2be06ba67e Improve doc/typing/message for ExceptionInfo.match (#6776) 2020-02-21 16:41:57 +01:00
Daniel Hahler
8e991a622c tests: harden/improve test_itemreport_subclasses_show_subclassed_file (#6467)
* tests: harden test_itemreport_subclasses_show_subclassed_file

* extend test_itemreport_subclasses_show_subclassed_file
2020-02-21 15:24:12 +01:00
Daniel Hahler
b099fcfa33 tests: runner: improve/ignore coverage (#6781) 2020-02-21 14:37:56 +01:00
Daniel Hahler
4c9b850e13 help: --deselect: mention that this uses node id prefixes (#6770)
Ref: https://github.com/pytest-dev/pytest/issues/6751
2020-02-21 12:53:27 +01:00
Daniel Hahler
81a9df6ed1 tests: fix flaky test_timeout (#6773)
Use a longer timeout on CI - seen a failure with it with GHA (Windows).

Ref: a4554e666a
2020-02-21 12:52:31 +01:00
Daniel Hahler
58ef95ed4d ci: fix Travis (#236) (#6786) 2020-02-21 12:50:54 +01:00
Bruno Oliveira
435ad221f9 Deprecate TerminalReporter.writer
Fix #6779
2020-02-20 21:04:49 -03:00
Daniel Hahler
d1b50526fa tests: harden some UsageError tests (matching the error msg) (#6775) 2020-02-20 13:29:59 +01:00
Daniel Hahler
4d633a29be cacheprovider: fix typing with Path(py.path.local) (#6774)
Fixes:

> Argument 1 to "Path" has incompatible type "Union[local, Any]";
> expected "Union[str, _PathLike[str]]"  [arg-type]

Ref: https://github.com/pytest-dev/py/pull/232#pullrequestreview-349549522
2020-02-20 13:23:41 +01:00
Daniel Hahler
8a1633c3b4 tmpdir: clean up indirection via config for factories (#6767)
Remove `_tmp_path_factory` and `_tmpdirhandler` from the config object.

- `_tmpdirhandler` has been deprecated since 2.8.0 (0f52856f9), when
  `tmpdir_factory` has been added.
- `_tmp_path_factory` should have probably never been added there in the
  first place, but maybe just used the same pattern (16e2737da).
2020-02-20 12:48:33 +01:00
Daniel Hahler
82f5986424 capture: re-order classes (#6768)
This better reflects the inheritance / smartness with regard to raw or
encoded.

- FDCaptureBinary
- FDCapture
- SysCaptureBinary
- SysCapture
- TeeSysCapture
2020-02-20 11:00:19 +01:00
Daniel Hahler
fb16d3e27a capture: revisit/fix __repr__, define _in_suspended (#6749) 2020-02-20 00:51:57 +01:00
Daniel Hahler
2b13a9b95d Use TYPE_CHECKING (#6771) 2020-02-19 22:07:54 +01:00
Daniel Hahler
1b30514783 LFPlugin: use sub-plugins to deselect during collection (#6448)
Fixes https://github.com/pytest-dev/pytest/issues/5301.

Refactor/steps:

- use var
- harden test_lastfailed_usecase
- harden test_failedfirst_order
- revisit last_failed_paths
- harden test_lastfailed_with_known_failures_not_being_selected
2020-02-19 21:33:03 +01:00
Ran Benita
af2b0e1174 Merge pull request #6758 from bluetech/outcome-exception-callable-2
Use a hack to make typing of pytest.fail.Exception & co work
2020-02-19 22:08:21 +02:00
Daniel Hahler
781a730bea terminal: remove confusing comment about _tw (#6763)
Ref: https://github.com/blueyed/pytest/commit/cf0cac3b7#r37373455
2020-02-19 20:35:50 +01:00
Nathaniel Compton
7c09d88b72 #6289: Add new example to XFAIL documentation (#6685)
Fix #6289

Co-authored-by: Ran Benita <ran234@gmail.com>
2020-02-19 15:04:37 -03:00
Daniel Hahler
4021770688 pytester: LineMatcher: use _fail with _match_lines_random (#6747) 2020-02-19 13:16:57 +01:00
Daniel Hahler
f95c7f5803 doctest: handle any OutcomeException (#6669)
Fixes using `pytest.xfail()` and `pytest.importorskip()` in doctests.

Ref: https://github.com/pytest-dev/pytest/issues/310
2020-02-19 13:16:37 +01:00
Ran Benita
24dcc76495 Use a hack to make typing of pytest.fail.Exception & co work
Mypy currently is unable to handle assigning attributes on function:
https://github.com/python/mypy/issues/2087.
pytest uses this for the outcome exceptions -- `pytest.fail.Exception`,
`pytest.exit.Exception` etc, and this is the canonical name by which they
are referred.

Initially we started working around this with type: ignores, and later
by switching e.g. `pytest.fail.Exception` with the direct exception
`Failed`. But this causes a lot of churn and is not as nice. And I also
found that some code relies on it, in skipping.py:

    def pytest_configure(config):
        if config.option.runxfail:
            # yay a hack
            import pytest

            old = pytest.xfail
            config._cleanup.append(lambda: setattr(pytest, "xfail", old))

            def nop(*args, **kwargs):
                pass

            nop.Exception = xfail.Exception
            setattr(pytest, "xfail", nop)
        ...

So it seems better to support it. Use a hack to make it work. The rest
of the commit rolls back all of the workarounds we added up to now.

`pytest.raises.Exception` also exists, but it's not used much so I kept
it as-is for now.

Hopefully in the future mypy supports this and this ugliness can be
removed.
2020-02-18 23:17:27 +02:00
Daniel Hahler
442f7a7706 Do not use fixed line number with test_cache_failure_warns (#6748)
It was not previously checking for the line number also (02aa8ad), and this is
obviously wrong (affected by changes to the file).
2020-02-18 09:27:33 +01:00
Daniel Hahler
d18c75baa3 doc: fix test with link to python_files (#6741)
Follow-up to b09762d (#6705).

Ref: https://github.com/pytest-dev/pytest/pull/6705#discussion_r379819573
2020-02-16 10:30:25 +01:00
Daniel Hahler
bc976dca3b pytester: add __tracebackhide__ for matching randomly (#6746) 2020-02-16 10:29:59 +01:00
Ran Benita
7b8968ff80 Merge pull request #6735 from bluetech/metafunc-annotate
Type annotate Metafunc
2020-02-15 23:32:14 +02:00
Ran Benita
0c68e7a2c9 Merge pull request #6744 from bluetech/item-runtest-stub
Add Item.runtest stub implementation
2020-02-15 23:27:57 +02:00
Daniel Hahler
369284752e terminal: refactor, no yellow ("boring") for non-last item (#6409) 2020-02-15 19:00:24 +01:00
Daniel Hahler
e872532d0c Merge branch 'master' into term-color
Conflicts:
	src/_pytest/terminal.py
	testing/test_debugging.py
	testing/test_terminal.py
2020-02-15 18:46:29 +01:00
kpinc
9785ee438d doc: expand first sentence on fixtures into a paragraph (#6742) 2020-02-15 18:35:36 +01:00
Ran Benita
959e6b4f44 Merge pull request #6743 from bluetech/runtest-getattr
Avoid getattr when dispatching pytest_runtest_* hooks
2020-02-15 17:22:00 +02:00
Ran Benita
5945c3fe88 Type annotate Metafunc 2020-02-15 17:13:18 +02:00
Ran Benita
7155b2277c Ignore "assert False" statements in coverage 2020-02-15 17:08:01 +02:00
Ran Benita
a7a1686433 Add Item.runtest stub implementation
Every Item must implement this method (called on all items collected in
a session). Add a stub for typing and clarity.
2020-02-15 16:58:55 +02:00
Ran Benita
371939fb86 Avoid getattr when dispatching pytest_runtest_* hooks
Using getattr doesn't work with typing, and also breaks grep. It took me
a while to find where these hooks are called.
2020-02-15 15:34:21 +02:00
Daniel Hahler
7fc9d4c976 Use warnings module directly with cacheprovider (#6740) 2020-02-15 05:31:18 +01:00
Daniel Hahler
2b5adc88a7 Move test_issue4445_cacheprovider_set into test_cache_failure_warns
Would need to be adjusted anyway non-trivially, and we can just harden
`test_cache_failure_warns` instead.
2020-02-15 02:01:22 +01:00
Daniel Hahler
02aa8adae1 cacheprovider: use warnings directly
Allows for filtering of PytestCacheWarning.

Using `_issue_warning_captured` is not necessary here, and was probably
only used because the cacheprovider misses warnings during
`pytest_sessionfinish`, which is also fixed here.

I think the usage of `_issue_warning_captured` can be removed/reduced
further, but also that this is good enough for now.

Ref: https://github.com/pytest-dev/pytest/issues/6681.
2020-02-15 01:36:57 +01:00
Daniel Hahler
67e69a7e49 tests: harden test_xdist_verbose (#6700) 2020-02-15 01:22:01 +01:00
Daniel Hahler
b09762df27 doc: link to python_files from "Assertion Rewriting" (#6705)
Ref: https://github.com/pytest-dev/pytest/issues/6377
Ref: https://github.com/blueyed/pytest/pull/145
2020-02-15 00:32:16 +01:00
Daniel Hahler
9631b3c166 reports: use attr.asdict with serialize_repr_{crash,traceback} (#6732)
* Turn ReprTraceback into attrs class

* Use attr.asdict with serialize_repr_{crash,traceback}

* Turn ReprFileLocation into attrs class, convert py.path.local
2020-02-14 19:39:34 +01:00
Daniel Hahler
4b70ba2c21 tests: harden test_better_reporting_on_conftest_load_failure (#6713) 2020-02-14 17:00:01 +01:00
Daniel Hahler
de3353aac1 test_load_initial_conftest_last_ordering: handle testing package (#6706) 2020-02-14 16:58:17 +01:00
Bruno Oliveira
ef73a56032 Merge pull request #6737 from bluetech/fixture-cached-result
Don't delete FixtureDef.cached_result, set it to None instead
2020-02-14 12:33:03 -03:00
Ran Benita
d839686c7b Don't delete FixtureDef.cached_result, set it to None instead
Previously `cached_result` was either set or deleted. Type annotations
cannot handle this, so use `None` for the non-set state instead.
2020-02-14 14:18:58 +02:00
Daniel Hahler
d89b5057ca assertrepr_compare: provide more info (location) with exceptions (#6728) 2020-02-14 02:17:05 +01:00
Daniel Hahler
83137c89e9 tests: test_unicode_plus_minus: use unicode sign directly (#6727)
Was globbed for Python 2 before (57c448991).
2020-02-14 02:16:25 +01:00
Daniel Hahler
dbae5a7ff8 Recognize -V as a short option for --version (#6721) 2020-02-13 12:30:22 +01:00
Daniel Hahler
07b7b6fa7d doc: add docstring for CaptureManager._capturing_for_request (#6698)
Based on the removed doc for `_install_capture_fixture_on_item`.

Follow-up to https://github.com/pytest-dev/pytest/pull/6663.

Co-authored-by: Ran Benita <ran234@gmail.com>
2020-02-13 12:09:32 +01:00
Ran Benita
56a5dbe252 Merge pull request #6722 from bluetech/rm-callspec2-global
Remove unused CallSpec2 fields _globalid, _globalparam
2020-02-13 12:49:41 +02:00
Ran Benita
8a4d5227e2 Remove unused CallSpec2 fields _globalid, _globalparam 2020-02-13 12:31:48 +02:00
Bruno Oliveira
e6ea9edffe Merge pull request #6673 from sscherfke/features
Reverse / fix meaning of "+/-" in error diffs
2020-02-12 15:05:38 -03:00
Daniel Hahler
b7ad4c2bed _pformat_dispatch: pass through args (#6715) 2020-02-12 16:07:57 +01:00
Bruno Oliveira
d79179a239 Merge pull request #6716 from bluetech/features-to-master-for-real
Merge the features branch into master, before stopping to use it
2020-02-12 11:52:32 -03:00
Ran Benita
c9f9664336 Merge branch 'features' into master
The features branch is no more. Development of features is now also done
on master.

See https://github.com/pytest-dev/pytest/pull/6571.
2020-02-12 13:50:02 +02:00
Bruno Oliveira
aa4d80cad9 RFC: Streamlining pytest's git workflow (#6571)
RFC: Streamlining pytest's git workflow
2020-02-12 08:37:14 -03:00
Bruno Oliveira
4209ad6fca Use code highlighting if pygments is installed (#6658)
* Use code highlighting if pygments is installed

* Use colorama constants instead of bare ascii codes

Could not find the exact equivalent of 'hl-reset' code using colorama
constants though.

* Refactor ASCII color handling into a fixture

* Revert back to using explicit color codes

* In Python 3.5 skip rest of tests that require ordered markup in colored output
2020-02-12 08:32:37 -03:00
Bruno Oliveira
3ea74310d7 Fix crash when faulthandler starts initialized (#6598)
Use suggestion in review and use a subplugin so hooks will only be active
if we enable faulthandler ourselves.

Fix #6575

Co-authored-by: Daniel Hahler <git@thequod.de>
2020-02-12 11:06:20 +01:00
Ran Benita
c3e53a072d Switch to new git workflow
Co-Authored-By: Daniel Hahler <git@thequod.de>
2020-02-12 09:49:21 +02:00
Daniel Hahler
fa877665ad _set_main_color: does not need to return 2020-02-12 03:11:54 +01:00
Bruno Oliveira
3b582858f3 Merge pull request #6712 from nicoddemus/mm
Merge master into features
2020-02-11 20:22:20 -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
7484e346f9 Merge pull request #6711 from bluetech/mv-exitcode
Move ExitCode's definition from _pytest.main to _pytest.config
2020-02-11 09:49:38 +02:00
Ran Benita
d25123eb01 Merge pull request #6710 from bluetech/rm-nodemarkers
Remove unused NodeMarkers
2020-02-10 23:57:40 +02: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
Stefan Scherfke
d59adc61f9 Reverse / fix meaning of "+/-" in error diffs
The convention is "assert result is expected".  Pytest's error diffs now
reflect this. "-" means that sth. expected is missing in the result and
"+" means that there are unexpected extras in the result.

Fixes: #3333
2020-02-10 21:12:37 +01:00
Ran Benita
7cc513b2af Remove unused NodeMarkers
This class was both added and became unused during the development of a
PR:
https://github.com/pytest-dev/pytest/pull/3317
2020-02-10 22:05:25 +02:00
Daniel Hahler
0ee007ca33 Fix CI (Travis) (#6704) 2020-02-10 20:52:21 +01:00
Ran Benita
1ebca37689 Merge pull request #6708 from bluetech/redundant-commas-2
Remove some redundant commas
2020-02-10 21:26:55 +02:00
Ran Benita
b59d32a5c7 Merge pull request #6709 from bluetech/rm-arg2finish
Remove unused field FixtureManager._arg2finish
2020-02-10 21:26:30 +02:00
Ran Benita
3e4e6297ce Remove unused field FixtureManager._arg2finish
Not used since 4f0879ff9b.
2020-02-10 17:30:20 +02:00
Ran Benita
0b2b40e35d Remove some redundant commas
Fix mypy errors:

src/_pytest/runner.py:36: error: "addoption" of "OptionGroup" does not return a value  [func-returns-value]
src/_pytest/helpconfig.py:64: error: "addoption" of "OptionGroup" does not return a value  [func-returns-value]
src/_pytest/terminal.py:67: error: "_addoption" of "OptionGroup" does not return a value  [func-returns-value]
src/_pytest/terminal.py:75: error: "_addoption" of "OptionGroup" does not return a value  [func-returns-value]
2020-02-10 17:28:05 +02:00
Daniel Hahler
f9dd58000a Fix CaptureManager.__repr__ (#6697) 2020-02-10 13:03:05 +01:00
Daniel Hahler
449290406c test_argcomplete: remove usage of distutils.spawn (#6703)
Fixes collection error with Python 3.5.3 (Travis):

    testing/test_parseopt.py:2: in <module>
        import distutils.spawn
    .tox/py35-coverage/lib/python3.5/distutils/__init__.py:4: in <module>
        import imp
    .tox/py35-coverage/lib/python3.5/imp.py:33: in <module>
        PendingDeprecationWarning, stacklevel=2)
    E   PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses

Build log: https://travis-ci.org/blueyed/pytest/builds/648305304
2020-02-10 11:52:19 +01:00
Daniel Hahler
12824e6279 ci: Travis: remove non-py35 jobs 2020-02-10 10:59:28 +01:00
Daniel Hahler
a62d9a40e7 ci: Travis: 3.5.1: upgrade pip, setuptools, virtualenv
Ref: https://github.com/jaraco/zipp/issues/40
2020-02-10 10:53:42 +01:00
Daniel Hahler
30cb598e9c Typing around/from types in docs (#6699) 2020-02-09 11:42:07 +01:00
Daniel Hahler
114de91ab7 factor out _determine_main_color
(cherry picked from commit f36b9f7fa4fa1af7130406166df5c2be668e50c9)
2020-02-09 00:26:38 +01:00
Daniel Hahler
7a7c634e33 factor out KNOWN_TYPES
(cherry picked from commit 1180aedee727f7e8468fdc5561a87e12865622c6)
2020-02-09 00:26:26 +01:00
Daniel Hahler
b4ace46c42 capture: cleanup item fixture handling (#6663)
This started by looking at how to get the current test item in general,
and then I noticed that it is not necessary for the capture plugin to
track it manually in the first place.
2020-02-07 19:23:37 +01:00
Daniel Hahler
a8fc056aad Handle Exit exception in pytest_sessionfinish (#6660) 2020-02-07 00:40:10 +01:00
Vladyslav Rachek
9e262038c8 [parametrize] enforce explicit argnames declaration (#6330)
Every argname used in `parametrize` either must
be declared explicitly in the python test function, or via
`indirect` list

Fix #5712
2020-02-06 20:20:25 -03:00
Minuddin Ahmed Rana
ef437ea448 Remove incorrect choices comment (#6677) 2020-02-05 20:45:21 +01:00
Daniel Hahler
cdc7e13067 pytester: clarify _makefile signature (#6675) 2020-02-05 20:42:57 +01:00
Daniel Hahler
39d9f7cff5 pytester: LineMatcher: typing, docs, consecutive line matching (#6653) 2020-02-04 22:47:18 +01:00
Daniel Hahler
632800add5 internal: clean up getfslineno (#6656) 2020-02-04 22:46:00 +01:00
Daniel Hahler
bc494661ad Remove testing/test_modimport.py (#6666) 2020-02-04 08:26:40 +01:00
Daniel Hahler
5a4c1b628b Use inspect.getdoc to massage fixture docstrings (#6668)
Ref: https://github.com/pytest-dev/pytest/pull/2575
2020-02-04 03:07:53 +01: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
aa0328782f assertion: save/restore hooks on item (#6646) 2020-02-04 02:56:23 +01:00
Daniel Hahler
9c7f1d9b32 Remove compat.getfslineno 2020-02-04 02:40:59 +01:00
Daniel Hahler
dab90ef726 typing: fix getfslineno
Closes https://github.com/pytest-dev/pytest/pull/6590.
2020-02-03 19:09:08 +01:00
Daniel Hahler
61f2a26675 Code/getfslineno: keep empty co_filename
Previously this would be turned via `py.path.local("")` into the current
working directory.

This appears to be what `fspath = fn and py.path.local(fn) or None`
tries to avoid in `getfslineno`'s `TypeError` handling already, if
`Code` would raise it.
2020-02-03 19:09:08 +01:00
Daniel Hahler
b0d45267c5 internal: clean up getfslineno
Everything was using `_pytest.compat.getfslineno` basically, which
wrapped `_pytest._code.source.getfslineno`.

This moves the extra code from there into it directly, and uses the
latter everywhere.

This helps to eventually remove the one in compat eventually, and also
causes less cyclic imports.
2020-02-03 19:09:08 +01:00
Bruno Oliveira
1480aa31a7 Explicitly state on the PR template that we can squash commits (#6662)
* Explicitly state on the PR template that we can squash commits

This way we don't need to ask every time, and users who for some reason
would not like us to squash their commits can explicitly state so.
2020-02-03 14:35:50 -03: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
abffd16ce6 Keep (revisited) comment from https://github.com/pytest-dev/pytest/commit/4d31ea831 2020-02-03 14:04:16 +01:00
Daniel Hahler
fb289667e3 Remove testing/test_modimport.py
testing/test_meta.py ensures this already as a side effect
(+ tests a few more (`__init__.py` files) and should have been
combined with it right away [1].

1: https://github.com/pytest-dev/pytest/pull/4510#discussion_r289123446

Ref: https://github.com/pytest-dev/pytest/commit/eaa05531e
Ref: https://github.com/pytest-dev/pytest/commit/4d31ea831
2020-02-03 13:58:32 +01:00
Daniel Hahler
8ec4d03c91 Inline FunctionMixin with Function (#6664)
`Generator` was removed in 7eb28f9eb, and this pleases mypy to correctly
complain that `FunctionMixin` has no `config` (within
`_prunetraceback`).

* typing: _prunetraceback

* minor: imports, typing
2020-02-03 10:25:32 +01:00
rebecca-palmer
c55bf23cbe doc: s/pytest_mark/pytestmark (#6661) 2020-02-03 08:56:37 +01:00
Daniel Hahler
99d162e44a Handle Exit exception in pytest_sessionfinish
Similar to a7268aa (https://github.com/pytest-dev/pytest/pull/6258).
2020-02-02 23:13:23 +01:00
Ran Benita
8bd612b367 typing: wrap_session
Pulled out of https://github.com/pytest-dev/pytest/pull/6556.
2020-02-02 23:12:48 +01:00
Daniel Hahler
5256542ea4 pytester.LineMatcher: add support for matching lines consecutively 2020-02-01 23:48:58 +01:00
Daniel Hahler
50f81db817 revisit/improve docstrings 2020-02-01 23:48:58 +01:00
Daniel Hahler
2681b0aed7 typing: pytester: LineMatcher 2020-02-01 23:48:57 +01:00
Daniel Hahler
b10ab0211c Use TypeError instead of AssertionError for no sequence
Improve/extends tests.
2020-02-01 23:48:57 +01:00
Daniel Hahler
09a0e45492 testing/test_pytester.py: cosmetics 2020-02-01 23:48:57 +01:00
Daniel Hahler
a9c5d31806 PyCollector._genfunctions: use already created fixtureinfo (#6636)
`Function` creates a `_fixtureinfo` already:
https://github.com/pytest-dev/pytest/blob/fed535694/src/_pytest/python.py#L1392-L1395
2020-02-01 06:27:41 +01:00
Hugo van Kemenade
c9eeafade5 Fix favicon for Chrome and Opera (#6639)
* Fix favicon for Chrome and Opera

* Delete pytest1favi.ico

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-01-31 20:56:45 -03:00
Bruno Oliveira
39b25ddcf3 Remove deprecated 'pytest_itemstart' hook (#6637)
Remove deprecated 'pytest_itemstart' hook
2020-01-31 16:12:27 -03:00
Ran Benita
4038d6c773 Merge pull request #6640 from bluetech/master-to-features
Merge master to features - one last time
2020-01-31 12:11:14 +02:00
Ran Benita
a435faad5c Merge branch 'master' into master-to-features 2020-01-31 11:27:06 +02:00
Daniel Hahler
3645ba3072 Merge pull request #6638 from blueyed/rfEX
tests: use `-rfEX`
2020-01-31 01:06:32 +01:00
Bruno Oliveira
70739296e1 Remove deprecated 'pytest_itemstart' hook
This hook has been deprecated/removed for more than 10 years
in a2fe6714f8.
2020-01-30 21:03:29 -03:00
Daniel Hahler
8301993e5e tests: use -rfEX
`-fE` is the default in `features` now [1], but the idea is to add `X`
also to it in the long run, so let's dogfood it ourselves.

1: https://github.com/pytest-dev/pytest/pull/6524
2: https://github.com/pytest-dev/pytest/pull/6524#issuecomment-577650703
2020-01-31 00:18:51 +01:00
Daniel Hahler
1dc265e34a Merge pull request #6633 from blueyed/async_warn
python: factor out async_warn
2020-01-30 23:39:06 +01:00
Daniel Hahler
e7a833635d Merge pull request #6635 from blueyed/fix-todo
minor: doc: getfuncargnames: move TODO out of docstring
2020-01-30 23:37:41 +01:00
Daniel Hahler
fed5356941 Merge pull request #6634 from blueyed/fixtures-move-import
fixtures: move import of ParameterSet to top level
2020-01-30 23:22:39 +01:00
Daniel Hahler
5b81bd862c minor: doc: getfuncargnames: move TODO out of docstring 2020-01-30 23:22:10 +01:00
Daniel Hahler
2902c7263c fixtures: move import of ParameterSet to top level
This gets typically used always (via `getfixtureinfo`).
2020-01-30 23:03:02 +01:00
Daniel Hahler
442dccef65 python: factor out async_warn 2020-01-30 22:55:23 +01:00
Daniel Hahler
e830432592 Merge pull request #6601 from blueyed/typing-pytest_collection
typing: pytest_collection
2020-01-30 20:47:06 +01:00
Daniel Hahler
ae788997f2 Merge pull request #6630 from blueyed/revert-curl
Revert "ci: codecov: use `--retry-connrefused` with curl"
2020-01-30 20:46:46 +01:00
Daniel Hahler
88b800355a typing: pytest_collection 2020-01-30 19:58:43 +01:00
Daniel Hahler
864338de71 Revert "ci: codecov: use --retry-connrefused with curl"
Not known with `curl` on Travis at least.

Reverts https://github.com/pytest-dev/pytest/pull/6573.

This reverts commit df1f43ee28.
2020-01-30 19:56:25 +01:00
Bruno Oliveira
eb5e651d7e Fix typo (#6629)
Fix typo
2020-01-30 13:41:47 -03:00
Hugo van Kemenade
55bffb7c15 Fix typo 2020-01-30 18:30:51 +02:00
Bruno Oliveira
be18f85a6e Reword fixture docs for clarity (#6627)
Reword fixture docs for clarity
2020-01-30 12:56:45 -03:00
Daniel Hahler
28b8f3ca3a Merge pull request #6461 from blueyed/test-package-upstream
Package: typing, cleanup
2020-01-30 16:41:47 +01:00
Daniel Arndt
d91459fc75 Reword fixture docs for clarity 2020-01-30 09:32:54 -04:00
Daniel Hahler
4de8e680e3 Merge pull request #6625 from blueyed/merge-master-into-features
Merge master into features
2020-01-30 02:53:56 +01:00
Bruno Oliveira
ef283efc42 Merge pull request #6624 from nicoddemus/gh-notes-wrap
Use --wrap=preserve in release notes script
2020-01-29 22:36:42 -03:00
Daniel Hahler
b5b6e051ed Merge master into features 2020-01-30 02:29:02 +01:00
Daniel Hahler
10b1b79f4e Merge pull request #6623 from blueyed/move-back-test_getfslineno
tests: move test_getfslineno back
2020-01-30 02:17:25 +01:00
Bruno Oliveira
6d7e06e6be Use --wrap=preserve in release notes script
Follow up to #6621 after premature merge
2020-01-29 20:28:04 -03:00
Daniel Hahler
78eddcb5b1 tests: move test_getfslineno back
Reverts https://github.com/pytest-dev/pytest/pull/6610.

The tested `getfslineno` is `src/_pytest/_code/source.py` actually,
exported via `src/_pytest/_code/__init__.py`.
I've confused it with the one in `src/_pytest/compat.py` apparently.
2020-01-29 23:47:39 +01:00
Bruno Oliveira
757873edb3 Docs: Don't wrap the markdown for GitHub releases (#6621)
Docs: Don't wrap the markdown for GitHub releases
2020-01-29 19:38:17 -03:00
Bruno Oliveira
64ab68ff0a Fix 6341 disallow session config in fromparent (#6387)
Fix 6341 disallow session config in fromparent
2020-01-29 19:21:02 -03:00
Daniel Hahler
66330444a3 Merge pull request #6611 from blueyed/test_code-imports
tests: test_code: improve/clarify imports
2020-01-29 21:23:37 +01:00
Hugo van Kemenade
97f1645993 Don't wrap the markdown for GitHub releases 2020-01-29 21:56:01 +02:00
Daniel Hahler
3dbc61dd80 tests: test_code: improve/clarify imports 2020-01-29 19:44:37 +01:00
Daniel Hahler
b42938421e Merge pull request #6610 from blueyed/tests-move-test_getfslineno
tests: move test_getfslineno
2020-01-29 19:43:28 +01:00
Daniel Hahler
87fecce77b Merge pull request #6600 from blueyed/harden-test_teardown_many_verbose
tests: harden test_teardown_many_verbose
2020-01-29 18:56:10 +01:00
Daniel Hahler
05d953d9e4 Merge pull request #6620 from blueyed/cp-release
doc: release-5.3.5
2020-01-29 18:42:27 +01:00
Daniel Hahler
d478e2bbca doc: release-5.3.4
(cherry picked from commit fd1a51a23f)
2020-01-29 18:28:11 +01:00
Anthony Sottile
595d62bc3e Merge pull request #6607 from asottile/empty_string_parametrize_nodeid
Fix node ids which contain a parametrized empty-string variable
2020-01-29 08:42:04 -08:00
Bruno Oliveira
8c41236c66 doc: getting-started.rst: mention "Test" prefix for classes (#6583)
doc: getting-started.rst: mention "Test" prefix for classes
2020-01-29 12:49:49 -03:00
Bruno Oliveira
99b90f45d0 extend the incremental marker for parametrize (#6582)
extend the incremental marker for parametrize
2020-01-29 08:37:33 -03:00
sdementen
d848a20563 Extend the incremental marker for parametrize
The incremental marker is adapted to handle properly test classes with parametrize defined at class level.

Fix #3125
2020-01-29 08:25:17 -03:00
Daniel Hahler
06a7fef00f Merge pull request #6616 from blueyed/merge-master-into-features
Merge master into features
2020-01-29 06:57:45 +01:00
Daniel Hahler
55e5817570 Merge master into features 2020-01-29 03:07:35 +01:00
Daniel Hahler
3f4b8d3aec test_code: improve coverage 2020-01-29 02:54:12 +01:00
Daniel Hahler
a3f482ceba tests: move test_getfslineno
It should be in `test_code` when testing `_pytest._code.getfslineno`,
not to be confused with `_pytest._code.source.getfslineno`.

Adds an extra assert (via https://github.com/pytest-dev/pytest/pull/6590).
2020-01-29 01:26:10 +01:00
Daniel Hahler
3ccf2a5e61 Merge pull request #6524 from blueyed/reportchars-default
terminal: default to `fE` with `-r` (reportchars)
2020-01-29 01:00:41 +01:00
Daniel Hahler
8e1d59a8dd Merge pull request #6579 from blueyed/pytester-makefile-joins-abspath
pytester: test for _makefile joining an absolute path
2020-01-29 00:58:43 +01:00
Daniel Hahler
7eaf98af4b Merge pull request #6589 from blueyed/ci-less-coverage
ci: GHA: run less jobs with coverage
2020-01-29 00:57:29 +01:00
Bruno Oliveira
d282424589 Fix unguarded == comparison in fixtures. (#6541)
Fix unguarded `==` comparison in fixtures.
2020-01-28 20:54:14 -03:00
Daniel Hahler
ddaa5d88ac terminal: default to fE with -r (reportchars)
Adds handling of `N` to reset `reportchars`, which can be used to get
the old behavior (`-rN`), and also allows for an alternative to
`--disable-warnings` (https://github.com/pytest-dev/pytest/issues/5066),
since `w` was included by default (without `--disable-warnings`).

Fixes https://github.com/pytest-dev/pytest/issues/6454
2020-01-29 00:33:15 +01:00
Daniel Hahler
4ff90b1fcf Merge pull request #6606 from blueyed/typing-monkeypatch-context
typing: MonkeyPatch.context
2020-01-29 00:12:53 +01:00
Daniel Hahler
2d29c3e7d1 Merge pull request #6604 from blueyed/tests-_compute_fixture_value-cover-abs-source_path_str
tests: cover absolute path handling in _compute_fixture_value
2020-01-29 00:11:58 +01:00
Anthony Sottile
abd5fc80e8 Fix node ids which contain a parametrized empty-string variable 2020-01-28 13:27:54 -08:00
Holger Kohr
80d4dd6f0b Replace == with is for comparison of cache keys
Closes #6497
2020-01-28 18:05:53 -03:00
Ran Benita
e440b43258 Merge pull request #6555 from bluetech/nodes-cache-split
Split Session._collection_node_cache to 3 mutually exclusive parts
2020-01-28 22:49:42 +02:00
Daniel Hahler
e25d46aae6 typing: MonkeyPatch.context 2020-01-28 21:44:30 +01:00
Daniel Hahler
7c87874277 source_path: py.path.local directly
Via bc7282576.
2020-01-28 19:02:41 +01:00
Daniel Hahler
1cf9e68dbc tests: cover absolute path handling in _compute_fixture_value 2020-01-28 18:53:28 +01:00
Daniel Hahler
b2e6f66438 ci: GHA: run less jobs with coverage
This often might be causing for jobs to take longer than 10 minutes,
which is a timeout Codecov uses to wait for successful CI.

Also it is good in general to have CI finish faster, of course.
2020-01-28 17:38:53 +01:00
Daniel Hahler
b01e379428 tests: harden test_teardown_many_verbose 2020-01-28 16:37:18 +01:00
Daniel Hahler
1586653102 Merge pull request #6594 from blueyed/merge-master-into-features
Merge master into features
2020-01-28 14:44:22 +01:00
Daniel Hahler
18ac7e0b79 Merge pull request #6593 from blueyed/typing-ignore-more-itertools
typing: ignore false positive with more-itertools
2020-01-28 14:24:24 +01:00
Ronny Pfannschmidt
c854daa234 Merge pull request #6595 from blueyed/fix-typing-code-path
typing: fix Code.path
2020-01-28 11:23:49 +01:00
Daniel Hahler
12c5a6af64 typing: fix Code.path
Fixes:

> src/_pytest/_code/code.py:83: error: Incompatible types in assignment
>   (expression has type "str", variable has type "local")  [assignment]
2020-01-28 01:49:45 +01:00
Daniel Hahler
30922ee694 Merge master into features 2020-01-28 01:40:14 +01:00
Daniel Hahler
35ba053f00 typing: ignore false positive with more-itertools
Fixed in https://github.com/erikrose/more-itertools/pull/374.
2020-01-28 01:23:44 +01:00
Daniel Hahler
d0cb16010b Merge pull request #6580 from blueyed/typing-testdir-init
typing: Testdir.__init__
2020-01-28 00:58:11 +01:00
Daniel Hahler
ad0f4f0ac0 tests: cover collect_by_name with non-existing 2020-01-28 00:41:46 +01:00
Daniel Hahler
9c716e4d74 typing: Testdir.plugins 2020-01-28 00:41:46 +01:00
Daniel Hahler
94ac0f7e6b typing: self._mod_collections, collect_by_name 2020-01-28 00:41:46 +01:00
Daniel Hahler
440881d63a typing: Testdir.__init__ 2020-01-28 00:41:46 +01:00
Daniel Hahler
aa318e9adf Merge pull request #6587 from blueyed/mypy-show_error_codes
mypy: show_error_codes=True
2020-01-27 22:58:48 +01:00
Daniel Hahler
20b66e60c0 Merge pull request #6566 from blueyed/rm-encodedfile-writelines
Fix `EncodedFile.writelines`
2020-01-27 22:58:31 +01:00
Daniel Hahler
d017b69f38 mypy: show_error_codes=True 2020-01-27 22:18:35 +01:00
Ran Benita
ae5d16be10 typing: FSHookProxy/gethookproxy
Taken out of https://github.com/pytest-dev/pytest/pull/6556.
2020-01-27 20:57:44 +01:00
ParetoLife
cbad319736 Update getting-started.rst
From the description it seemed to me as if just prefixing your methods with ``test_`` was enough, but you also need to prefix your class with ``Test``. Of course, in the reference material this is clearly stated, but I think it makes sense to mention it here as well, since you also mention the part about the methods' prefix.
2020-01-27 10:50:05 +01:00
Zac Hatfield-Dodds
a9eab07739 Merge pull request #6576 from blueyed/test_via_exec
tests: add test_via_exec
2020-01-27 17:57:28 +11:00
Daniel Hahler
c2980eb80f pytester: test for _makefile joining an absolute path
Ref: https://github.com/pytest-dev/pytest/pull/6578#discussion_r371035867
2020-01-27 01:00:55 +01:00
Daniel Hahler
bf5c76359c fixup! typing: tests: tmpfile 2020-01-26 23:14:32 +01:00
Daniel Hahler
40758e86ca tests: add test_via_exec
Via https://github.com/pytest-dev/pytest/issues/6574.
2020-01-26 23:04:18 +01:00
Daniel Hahler
d678d380cb typing: tests: tmpfile 2020-01-25 19:21:19 +01:00
Daniel Hahler
3f8f395210 typing: EncodedFile 2020-01-25 19:20:48 +01:00
Daniel Hahler
7c52a37d46 Merge pull request #6572 from blueyed/fix-test_collection_collect_only_live_logging
tests: test_collection_collect_only_live_logging: allow for 1+s
2020-01-25 19:05:37 +01:00
Daniel Hahler
198b1dcffd Merge pull request #6573 from blueyed/codecov-curl-retry-connrefused
ci: codecov: use `--retry-connrefused` with curl
2020-01-25 19:05:13 +01:00
Daniel Hahler
e2934c3f8c Move common code between Session and Package to FSCollector 2020-01-25 19:04:01 +01:00
Daniel Hahler
6b7e1a246c Sync {Session,Package}.gethookproxy
Only copy'n'paste error from c416b1d935.
2020-01-25 19:04:01 +01:00
Daniel Hahler
817c094ce6 Clean up Package.__init__
Makes `parent` a required arg, which would have failed before via
`parent.session` anyway.

Keeps calling/passing unused args for B/C.
2020-01-25 19:04:01 +01:00
Daniel Hahler
df1f43ee28 ci: codecov: use --retry-connrefused with curl
While it might not help with the following, it certainly might happen as
well.

```
+ curl -S -L --connect-timeout 5 --retry 6 -s https://codecov.io/bash -o codecov-upload.sh
curl: (16) Error in the HTTP2 framing layer
```
2020-01-25 18:22:03 +01:00
Daniel Hahler
778d4364fa tests: test_collection_collect_only_live_logging: allow for 1s
Might be slow on CI.

Ref: https://github.com/pytest-dev/pytest/pull/6570/checks?check_run_id=408752475#step:6:109
2020-01-25 18:14:49 +01:00
Daniel Hahler
039d582b52 Fix EncodedFile.writelines
This is implemented by the underlying stream already, which additionally
checks if the stream is not closed, and calls `write` per line.

Ref/via: https://github.com/pytest-dev/pytest/pull/6558#issuecomment-578210807
2020-01-25 18:06:50 +01:00
Daniel Hahler
9b8039cf09 Sync {Session,Package}._recurse 2020-01-25 16:44:20 +01:00
Daniel Hahler
b687f20d25 Merge pull request #6375 from hugovk/rm-deprecated-license_file-metadata
Remove deprecated license_file from setup.cfg
2020-01-25 16:20:48 +01:00
Daniel Hahler
510be29db8 Merge pull request #6534 from blueyed/test_plugin_loading_order
tests: add test_plugin_loading_order
2020-01-25 16:20:06 +01:00
Hugo
fe343a79f8 Remove deprecated license_file from setup.cfg
Starting with wheel 0.32.0 (2018-09-29), the `license_file` option is deprecated.

* https://wheel.readthedocs.io/en/stable/news.html

The wheel will continue to include `LICENSE`, it is now included automatically:

* https://wheel.readthedocs.io/en/stable/user_guide.html#including-license-files-in-the-generated-wheel-file

And `LICENSE` is still included in sdists thanks to setuptools-scm:

* https://github.com/pytest-dev/pytest/pull/6348#issuecomment-567836331
2020-01-25 17:08:00 +02:00
Daniel Hahler
1e3bc1814d typing for test_summary_stats 2020-01-25 15:09:02 +01:00
Daniel Hahler
57512aa997 _get_main_color: no yellow ("boring") for non-last item
- refactor _get_main_color/build_summary_stats_line
- factor out property _is_last_item; test_summary_stats: tr._is_last_item
- _write_progress_information_filling_space: remove color arg
- use setter for stats, handling main color
- _get_main_color: skip cache for last item
- Handle random order in test for py35.
2020-01-25 15:09:02 +01:00
Daniel Hahler
2e8f7ef31b Merge pull request #6569 from blueyed/merge-master-into-features
Merge master into features
2020-01-25 14:40:24 +01:00
Daniel Hahler
c51173d426 Merge master into features 2020-01-25 14:18:02 +01:00
Daniel Hahler
2da331ea9c Merge pull request #6568 from bluetech/redundant-commas
Remove a couple of redundant commas
2020-01-25 14:17:01 +01:00
Ran Benita
94d8c071b6 Remove a couple of redundant commas
Mypy complains about this once the function is typed:

src/_pytest/main.py:85: error: "_addoption" of "OptionGroup" does not return a value
src/_pytest/main.py:133: error: "addoption" of "OptionGroup" does not return a value
2020-01-25 14:12:47 +01:00
Daniel Hahler
0d55fb3797 Merge pull request #6567 from blueyed/codecov-config
ci: codecov: only use "comment: off"
2020-01-25 14:00:32 +01:00
Ran Benita
f3967333a1 Split Session._collection_node_cache to 3 mutually exclusive parts
Previously, this cache was used with 3 different and mutually exclusive
key-type -> value-type combinations. Mypy can't properly type this. It's
also quite confusing.

Split to 3 different dicts instead.
2020-01-25 14:31:12 +02:00
Ran Benita
a76bc64c54 Merge pull request #6547 from bluetech/session-initialparts
Refactor Session._initialparts to have a more explicit type
2020-01-25 14:30:26 +02:00
Ran Benita
dd5c2b22bd Refactor Session._initialparts to have a more explicit type
Previously, _initialparts was a list whose first item was a
`py.path.local` and the rest were `str`s. This is not something that
mypy is capable of modeling. The type `List[Union[str, py.path.local]]`
is too broad and would require asserts for every access.

Instead, make each item a `Tuple[py.path.local, List[str]]`. This way
the structure is clear and the types are accurate.

To make sure any users who might have been accessing this (private)
field will not break silently, change the name to _initial_parts.
2020-01-25 13:57:49 +02:00
Daniel Hahler
a29d6194f5 ci: codecov: only use "comment: off"
The changes status is quite buggy, remove it for now.
This just uses "comment: off" then.
2020-01-25 11:14:00 +01:00
Daniel Hahler
6f2943c7b3 Merge pull request #6558 from gavento/patch-1
Make EncodedFile.write() return the return value from inner write()
2020-01-25 11:04:12 +01:00
Tomáš Gavenčiak
5e15c86cc6 Fix EncodedFile.write return value
Make EncodedFile, used for captured output streams, method .write return
the number of characters written. Add test for captured stderr write.
Fixes #6557.

Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2020-01-25 10:36:23 +01:00
Daniel Hahler
498884a2a0 Merge pull request #6563 from blueyed/merge-master-into-features
Merge master into features
2020-01-25 00:31:58 +01:00
Daniel Hahler
09bdbffbde Merge master into features
Conflicts:
	src/_pytest/_code/code.py
	src/_pytest/main.py
2020-01-24 23:44:50 +01:00
Daniel Hahler
09ab5fd7e9 Merge pull request #6529 from blueyed/fix-test_repr_traceback_with_invalid_cwd
tests: fix test_repr_traceback_with_invalid_cwd
2020-01-24 23:41:31 +01:00
Daniel Hahler
040a61e22c Merge pull request #6550 from blueyed/doc-cleandir-cd-back
doc/en/fixture.rst: chdir back to previous directory
2020-01-24 23:41:08 +01:00
Daniel Hahler
2c32dad343 Merge pull request #6554 from blueyed/test_fixture_arg_ordering
tests: add test_fixture_arg_ordering
2020-01-24 23:40:58 +01:00
Daniel Hahler
8a8f9bd751 Merge pull request #6562 from blueyed/ci-rm-azure
ci: remove Azure config/scripts
2020-01-24 23:39:57 +01:00
Daniel Hahler
192d3adda3 tests: add test_fixture_arg_ordering
This is a regression test for part of
https://github.com/pytest-dev/pytest/issues/6492, testing one of the
fixes in https://github.com/pytest-dev/pytest/pull/6551.
2020-01-24 17:48:08 -03:00
Daniel Hahler
5865520c51 Merge pull request #6561 from blueyed/ci-gha-name-flag
ci: GHA: codecov: set CODECOV_NAME, OS in flags
2020-01-24 20:04:12 +01:00
Daniel Hahler
e2fa78c99f ci: remove Azure config/scripts
This is covered by GitHub Actions now.
2020-01-24 19:49:57 +01:00
Daniel Hahler
fe895a40b6 Merge pull request #6559 from blueyed/ci-travis-remove-linting
ci: Travis: removing linting,docs,doctesting
2020-01-24 19:45:42 +01:00
Daniel Hahler
934f38995a ci: GHA: codecov: set CODECOV_NAME, OS in flags 2020-01-24 19:42:51 +01:00
Daniel Hahler
5dcd24fecb Merge pull request #6553 from blueyed/ci-gha-use-report-coverage.sh
ci: GHA: use scripts/report-coverage.sh
2020-01-24 19:20:23 +01:00
Daniel Hahler
e5a362d0f5 ci: GHA: use scripts/report-coverage.sh 2020-01-24 18:00:38 +01:00
Daniel Hahler
f8654e6656 ci: Travis: removing linting,docs,doctesting
This is handled by GHA already, and not affected/required for coverage.
2020-01-24 17:26:10 +01:00
Daniel Hahler
0d4f479aa8 Merge pull request #6552 from blueyed/ci-linting
ci: GHA: separate jobs for linting, docs, doctesting
2020-01-24 13:36:59 +01:00
Daniel Hahler
79d00ab35a Merge pull request #6549 from blueyed/fix-release-minor
doc: minor fixes for the release process
2020-01-24 13:36:48 +01:00
Daniel Hahler
79ae86cc3f tests: fix test_repr_traceback_with_invalid_cwd
This never worked as expected (since a912d3745), and only py38-windows
triggered the mocked `os.getcwd` unintentionally, via `inspect`.
2020-01-24 12:52:12 +01:00
Daniel Hahler
c051a9e7b9 ci: GHA: separate jobs for linting, docs, doctesting
It helps to know upfront that e.g. linting failed, and makes finding the
error easier.
2020-01-24 12:29:35 +01:00
Daniel Hahler
cdd6f86e43 bug-fix fixes 2020-01-23 20:34:21 +01:00
Daniel Hahler
83451b548f doc/en/fixture.rst: chdir back to previous directory
This is considered to be best practice, and should be used in docs
therefore.
2020-01-23 19:09:18 +01:00
Daniel Hahler
38538c6c6d Merge pull request #6548 from blueyed/ci-codecov-flag-gha
ci: codecov: add flag for GHA
2020-01-23 18:39:50 +01:00
Daniel Hahler
55ebd9f803 doc: minor fixes for the release process 2020-01-23 18:31:48 +01:00
Daniel Hahler
8ca8d25202 Merge pull request #6545 from blueyed/terminalwriter
config: typing for create_terminal_writer, re-export TerminalWriter
2020-01-23 15:42:18 +01:00
Daniel Hahler
a8d67f5e7b ci: codecov: add flags for GHA/Travis
This would help with debugging missing coverage when removing Travis
jobs.
2020-01-23 15:41:41 +01:00
Daniel Hahler
03bc8aba4e config: typing for create_terminal_writer, re-export TerminalWriter
This also imports `TerminalWriter` explicitly via `_pytest._io`,
allowing for easier extending / replacing it.
2020-01-23 14:09:37 +01:00
Daniel Hahler
6b13379f37 Merge pull request #6521 from blueyed/harden-nose-raises
tests: improve test for `nose.raises`
2020-01-23 13:42:14 +01:00
Ran Benita
9dcdea5de7 Rewrite Item.location to be clearer with regard to types 2020-01-23 13:25:15 +01:00
Daniel Hahler
863bab5326 Merge pull request #6544 from blueyed/doc-rm-costlysetup
doc: remove costlysetup example
2020-01-23 13:21:32 +01:00
Daniel Hahler
8521503246 Merge pull request #6527 from blueyed/typing-getfslineno
typing: fix/adjust _code.source.getfslineno
2020-01-23 13:17:47 +01:00
Ran Benita
0b6258ab5b PyCollector.collect: use explicit cast to str
Ref: https://github.com/pytest-dev/pytest/pull/6521#pullrequestreview-347234792
2020-01-23 12:54:52 +01:00
Daniel Hahler
b63cb18776 doc: remove costlysetup example
It is not included with docs, and
`example/costlysetup/sub_a/test_quick.py::test_quick` sleeps for 5s,
slowing down `doctesting` unnecessarily.
2020-01-23 12:23:30 +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
10e243d206 Merge pull request #6543 from blueyed/rm-rw
tests: remove unnecessary `-rw` option
2020-01-23 11:56:07 +01:00
Daniel Hahler
e7444bbd5e tests: remove unnecessary -rw option
Warnings are enabled by default, which is tested by `test_getreportopt`.
2020-01-23 11:37:19 +01:00
Daniel Hahler
eb7a57f965 Merge pull request #6542 from blueyed/fix-test_record_property
tests: fix/harden test_record_property
2020-01-23 11:14:37 +01:00
Daniel Hahler
252eae5bc8 tests: fix/harden test_record_property
`-rv` is not a recognized reportchar.  Probably `-v` was meant, but is
not necessary to check that there are no warnings.

Followup to 2018cf12b (https://github.com/pytest-dev/pytest/pull/3360).
2020-01-23 10:49:59 +01:00
Daniel Hahler
9c7b3c57d7 typing: PyobjMixin.reportinfo, getfslineno 2020-01-23 10:45:31 +01:00
Daniel Hahler
1350c601dc Node.location: handle str with _node_location_to_relpath 2020-01-23 10:45:31 +01:00
Daniel Hahler
ef112fd7dd Revert "Revert "Fix type errors after adding types to the py dependency""
Without changes to test_itemreport_reportinfo.

This reverts commit fb99b5c66e.

Conflicts:
	testing/test_nose.py
2020-01-23 10:45:27 +01:00
Daniel Hahler
8fa57c8384 tests: improve test for nose.raises
This should probably get transferred into a `pytest.fail` really, but
tests/documents the current behavior.
2020-01-23 10:45:26 +01:00
Daniel Hahler
ad02f6f879 Merge pull request #6525 from blueyed/typing-session
typing: Session.__init__
2020-01-23 00:16:08 +01:00
Daniel Hahler
bd6ba3f3e1 typing: Session.__init__
Pulled out of https://github.com/pytest-dev/pytest/pull/6491.
2020-01-23 00:07:59 +01:00
Bruno Oliveira
e17f5fad14 Clear node collection cache after collection is done (#6491)
Clear node collection cache after collection is done
2020-01-22 16:08:59 -03:00
Daniel Hahler
72d06e6dec Merge pull request #6539 from blueyed/merge-master-into-features
Merge master into features
2020-01-22 19:32:49 +01:00
Daniel Hahler
aca1723d45 Merge master into features 2020-01-22 19:18:13 +01:00
Daniel Hahler
85df6bbe26 Merge pull request #6536 from blueyed/fix-test_cwd_snapshot
tests: fix test_cwd_snapshot
2020-01-22 16:46:04 +01:00
Daniel Hahler
ba49581510 Merge pull request #6538 from blueyed/test-coverage
tests: use NotImplementedError with uncovered code
2020-01-22 16:45:20 +01:00
Bruno Oliveira
0bf9628e62 Merge master into features (#6537)
Merge master into features
2020-01-22 12:43:19 -03:00
Daniel Hahler
d878d9d4d5 tests: use NotImplementedError with uncovered code 2020-01-22 15:38:12 +01:00
Bruno Oliveira
93b74d28d2 Merge remote-tracking branch 'upstream/master' into mm
Conflicts:
 * 	src/_pytest/_code/code.py
 * 	src/_pytest/main.py
 * 	testing/python/metafunc.py
 * 	testing/test_parseopt.py
 * 	testing/test_pytester.py
2020-01-22 11:03:45 -03:00
Daniel Hahler
8c4dfca0c1 Merge pull request #6535 from blueyed/tox-doctesting
tox: move doctesting into main testenv
2020-01-22 14:38:34 +01:00
Daniel Hahler
b8787b8732 tests: fix test_cwd_snapshot
Without restoring the cwd, successive tests might fail to parse the
config (via `_pytest.config._prepareconfig()`, for when `--lsof` is
used).

And it is good practice to restore the cwd in any case anyway.
2020-01-22 14:34:11 +01:00
Daniel Hahler
ef294fc727 tox: move doctesting into main testenv
This allows for `tox -e doctesting-coverage`, which would otherwise not
use the "doctesting" testenv.
2020-01-22 13:32:30 +01:00
Daniel Hahler
0f78ef8e02 Merge pull request #6532 from blueyed/harden-test
--cache-clear: add test for keeping non-supporting files
2020-01-22 12:20:24 +01:00
Daniel Hahler
1cd4bafda7 Merge pull request #6531 from blueyed/ci-gha-success
ci: GHA: remove unnecessary check for `success()`
2020-01-21 22:38:50 +01:00
Daniel Hahler
8f5fd537d8 --cache-clear: add test for keeping non-supporting files
Ref: https://github.com/pytest-dev/pytest/pull/6296
2020-01-21 22:16:56 +01:00
Daniel Hahler
9869a3d9e1 ci: GHA: remove unnecessary check for success()
Following jobs get aborted on failure.

Ref: https://github.com/pytest-dev/pytest/pull/6530
2020-01-21 21:44:49 +01:00
Daniel Hahler
2f00b041e4 Merge pull request #6526 from blueyed/typing-code-path
doc: fix Code.path: might return str
2020-01-21 21:06:26 +01:00
Daniel Hahler
62db3f7abc typing: fix/adjust _code.source.getfslineno 2020-01-21 19:48:17 +01:00
Daniel Hahler
7ee27fedee doc: fix Code.path: might return str 2020-01-21 19:46:43 +01:00
Bruno Oliveira
7b1e3d1c9a Clear collection caches after collection is done
Also rename the involved variables to convey its intent better and
add type hints
2020-01-21 07:29:13 -03:00
Ran Benita
a52f791461 Merge pull request #6518 from bluetech/fix-py-typed-fixes-regression
Fix internal assert failure regression in 5.3.4
2020-01-21 00:01:07 +02:00
Ran Benita
fb99b5c66e Revert "Fix type errors after adding types to the py dependency"
This reverts commit 930a158a6a.

Regression test from Bruno Oliveira.
2020-01-20 23:44:56 +02:00
Bruno Oliveira
ddfa41b5a7 Preparing release version 5.3.4 (#6516)
Preparing release version 5.3.4
2020-01-20 14:26:52 -03:00
Bruno Oliveira
6a26ac4125 Preparing release version 5.3.4 2020-01-20 13:53:31 -03:00
Bruno Oliveira
cdaa9c06e1 Revert "fixtures register finalizers with all fixtures before t… (#6496)
Revert "fixtures register finalizers with all fixtures before them in the stack"
2020-01-20 13:49:00 -03:00
Bruno Oliveira
0dc82e8501 Add CHANGELOG entry for #6496 2020-01-20 13:32:27 -03:00
Daniel Hahler
f9bed82c4d Merge pull request #6515 from blueyed/tox-mypy-diff
tox: add mypy-diff testenv
2020-01-20 14:29:15 +01:00
Daniel Hahler
2406076611 tox: add mypy-diff testenv 2020-01-20 13:42:07 +01:00
Ran Benita
44eb1f580c Merge pull request #6311 from bluetech/type-annotations-10
Some type annotation & check_untyped_defs fixes
2020-01-19 20:17:32 +02:00
Ran Benita
3392be37e1 Fix check_untyped_defs in test_runner 2020-01-19 20:01:07 +02:00
Ran Benita
3d2680b31b Fix type of pytest.warns, and fix check_untyped_defs in test_recwarn
The expected_warning is optional.
2020-01-19 19:39:14 +02:00
Ran Benita
0b603156b9 Fix check_untyped_defs errors in test_pytester 2020-01-19 19:39:14 +02:00
Ran Benita
0c247be769 Add a few missing type annotations in _pytest._code
These are more "dirty" than the previous batch (that's why they were
left out). The trouble is that `compile` can return either a code object
or an AST depending on a flag, so we need to add an overload to make the
common case Union free. But it's still worthwhile.
2020-01-19 19:39:14 +02:00
Ran Benita
3e6f0f34ff Cleanup unhelpful alias _AST_FLAG
Also replace one direct call to `compile` with this flag with the
equivalent wrapper `ast.parse`. This function can have a more precise
type.
2020-01-19 19:19:34 +02:00
Ran Benita
4fb9cc3bf0 Merge pull request #6511 from bluetech/py-typed-fixes
Fix type errors after adding types to the `py` dependency
2020-01-19 15:23:14 +02:00
Ran Benita
930a158a6a Fix type errors after adding types to the py dependency 2020-01-19 14:48:24 +02:00
Daniel Hahler
d347a30656 Merge pull request #6510 from blueyed/typing-fixes
typing: fix some "incompatible types in assignment" with py
2020-01-19 13:01:35 +01:00
Daniel Hahler
32b62f770f Merge pull request #6509 from blueyed/typing-minor
typing: minor improvements
2020-01-19 11:33:41 +01:00
Daniel Hahler
aaae43e0ba typing: fix some "incompatible types in assignment" with py 2020-01-19 11:32:45 +01:00
Daniel Hahler
1a75a3c08e Merge pull request #6482 from blueyed/fix-_TracebackStyle
typing: fix _TracebackStyle
2020-01-19 11:24:05 +01:00
Daniel Hahler
09e9a01df3 typing: fix _TracebackStyle: add "line" 2020-01-19 11:22:47 +01:00
Daniel Hahler
4b974b051d Merge pull request #6507 from blueyed/fix-test_excinfo
tests: test_excinfo: remove unused pytest_version_info
2020-01-19 11:21:46 +01:00
Daniel Hahler
5c445b05e7 typing: py.io.TerminalWriter for tw arguments 2020-01-19 11:21:16 +01:00
Daniel Hahler
4e0dbe92dd Node.name: str 2020-01-19 11:21:16 +01:00
Daniel Hahler
956389fa8c Session._fixturemanager 2020-01-19 11:21:16 +01:00
Daniel Hahler
61f985f3c7 tests: test_excinfo: remove unused pytest_version_info
This might fail unnecessarily with a (wrong) determined version of e.g.
"4.7.dev307+ge98176cf5" (no patch version).
Ref: https://github.com/pytest-dev/pytest/pull/6506
2020-01-19 08:11:13 +01:00
Daniel Hahler
2f0d0fb349 Merge pull request #6503 from blueyed/ci-travis-features
[features] ci: Travis: drop deploy and non-coverage jobs
2020-01-18 22:22:21 +01:00
Daniel Hahler
e98176cf50 Merge pull request #6501 from blueyed/test_color_yes
tests: terminal: harden test_color_yes
2020-01-18 16:11:27 +01:00
Daniel Hahler
38fc208205 tests: terminal: harden/improve test_color_yes 2020-01-18 15:49:59 +01:00
Daniel Hahler
89f92a459a ci: Travis: remove non-coverage jobs
This helps with regard to slowness until
https://github.com/pytest-dev/pytest/pull/6470 is resolved.

(cherry picked from commit a7292a0544)
2020-01-18 15:12:44 +01:00
Bruno Oliveira
40d0031cce Drop deploy from Travis in favor of GitHub actions
GitHub actions already should deploy.

This is a stop gap while we figure out why coverage dropped
when removing Travis builds in #6470

(cherry picked from commit d1d7e5d41b)
2020-01-18 15:12:44 +01:00
Daniel Hahler
d0811c1f3d Merge pull request #6502 from blueyed/fix-ci-features
[features] fix CI
2020-01-18 15:12:13 +01:00
Daniel Hahler
ac41f36a02 Merge pull request #6500 from blueyed/ci-travis
ci: Travis: remove non-coverage jobs
2020-01-18 14:53:03 +01:00
Daniel Hahler
7a626921c0 [features] tests: fix test_crash_on_closing_tmpfile_py27
(cherry picked from commit 4f0eec2022)
2020-01-18 14:52:18 +01:00
Daniel Hahler
59bc6efbf2 Merge pull request #6498 from blueyed/test_terminal_colors
test_terminal: improve color handling
2020-01-18 13:36:42 +01:00
Daniel Hahler
a7292a0544 ci: Travis: remove non-coverage jobs
This helps with regard to slowness until
https://github.com/pytest-dev/pytest/pull/6470 is resolved.
2020-01-18 13:35:44 +01:00
Daniel Hahler
1971033051 Merge pull request #6499 from blueyed/fix-ci
tests: fix test_crash_on_closing_tmpfile_py27
2020-01-18 13:35:11 +01:00
Daniel Hahler
d4d04e7f25 test_terminal: improve color handling 2020-01-18 13:16:27 +01:00
Daniel Hahler
4f0eec2022 tests: fix test_crash_on_closing_tmpfile_py27 2020-01-18 13:15:40 +01:00
Bruno Oliveira
cc7f294cfe Revert "fixtures register finalizers with all fixtures before them in the stack"
This reverts commit 99180939fe.
2020-01-17 12:55:57 -03:00
Bruno Oliveira
e1298faef9 Merge pull request #6481 from nicoddemus/release-5.3.3
Release 5.3.3
2020-01-17 08:07:57 -03:00
Daniel Hahler
e211d6fe2a Merge pull request #6488 from blueyed/typing-fix-reportinfo
typing: Node.reportinfo: might return py.path.local via fspath
2020-01-17 11:52:01 +01:00
Bruno Oliveira
544b4a14d5 Fix Hugo van Kemenade name in release announcement
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-01-17 07:18:57 -03:00
Daniel Hahler
4a42deee7e typing: Node.reportinfo: might return py.path.local via fspath 2020-01-17 11:05:46 +01:00
Daniel Hahler
2cce026766 Merge pull request #6476 from blueyed/fix-test_config
Fix test_config: wrong assertions, lint, unused fixtures
2020-01-17 10:31:41 +01:00
Daniel Hahler
e16cb2fdd0 Merge pull request #6444 from blueyed/fix-test_xfail_handling
tests: test_xfail_handling: use sys.dont_write_bytecode
2020-01-17 10:28:23 +01:00
Daniel Hahler
dcb94d8f31 Merge pull request #6485 from blueyed/lint-fix-f999
scripts/release.py: lint: fix F999
2020-01-17 09:13:04 +01:00
Daniel Hahler
19f66cb824 Merge pull request #6434 from blueyed/pytester-typing-spawn
pytester: typing for `spawn`/`spawn_pytest`
2020-01-17 06:57:40 +01:00
Daniel Hahler
36944157f8 pytester: typing for spawn/spawn_pytest 2020-01-17 05:58:25 +01:00
Daniel Hahler
2cfee583db scripts/release.py: lint: fix F999 2020-01-17 05:54:17 +01:00
Bruno Oliveira
56dc301c50 Preparing release version 5.3.3 2020-01-16 18:55:41 -05:00
Bruno Oliveira
aa05334984 Remove broken link for user @jgsonesen 2020-01-16 18:51:33 -05:00
Bruno Oliveira
4806878a7f Drop deploy from Travis in favor of GitHub actions (#6480)
Drop deploy from Travis in favor of GitHub actions
2020-01-16 18:34:44 -03:00
Bruno Oliveira
d1d7e5d41b Drop deploy from Travis in favor of GitHub actions
GitHub actions already should deploy.

This is a stop gap while we figure out why coverage dropped
when removing Travis builds in #6470
2020-01-16 18:12:47 -03:00
Daniel Hahler
1667cf3350 Merge pull request #6384 from pv/showlocals-short
Make --showlocals work together with --tb=short

Fixes https://github.com/pytest-dev/pytest/issues/494
Ref: https://github.com/pytest-dev/pytest/issues/1715
2020-01-16 22:04:14 +01:00
Daniel Hahler
5b0e255e85 Merge pull request #6465 from blueyed/doc-rootdir
doc: revisit section about rootdir
2020-01-16 21:55:12 +01:00
Daniel Hahler
f0fdafeddc Merge pull request #6477 from blueyed/tests-cleanup-unused-fixtures
tests: cleanup unused fixtures
2020-01-16 21:53:56 +01:00
Daniel Hahler
a4f5b8a4d6 Merge pull request #6478 from blueyed/merge-master-into-features
Merge master into features
2020-01-16 21:14:30 +01:00
Daniel Hahler
5049e25a6a tests: cleanup unused fixtures 2020-01-16 21:12:48 +01:00
Daniel Hahler
d36c712bb0 Merge pull request #6479 from blueyed/tests-fix-master
[master] Use a dummy RemoteTraceback for test in Python 3.5 Windows
2020-01-16 21:12:04 +01:00
Bruno Oliveira
7a0d1b387d Use a dummy RemoteTraceback for test in Python 3.5 Windows
Somehow in Python 3.5 on Windows this test fails with:
   File "c:\hostedtoolcache\windows\python\3.5.4\x64\Lib\multiprocessing\connection.py", line 302, in _recv_bytes
     overlapped=True)
OSError: [WinError 6] The handle is invalid

This only happens in this platform and Python version, decided to use
a dummy traceback as originally done in #6412.

(cherry picked from commit b9c136b809)
2020-01-16 20:03:16 +01:00
Daniel Hahler
5f4cd536f9 Use _pytest.compat.TYPE_CHECKING 2020-01-16 19:47:23 +01:00
Daniel Hahler
83813bf515 Merge master into features
Conflicts:
	.github/workflows/main.yml
2020-01-16 19:45:52 +01:00
Daniel Hahler
749752d440 Merge pull request #6435 from blueyed/type_checking
Use TYPE_CHECKING instead of False
2020-01-16 19:45:00 +01:00
Daniel Hahler
118cb3d3be Fix test_config: wrong assertions, lint, unused fixtures 2020-01-16 19:27:46 +01:00
Bruno Oliveira
b91c721262 ci: github actions: only deploy pytest-dev/pytest (#6474)
ci: github actions: only deploy pytest-dev/pytest
2020-01-16 12:48:29 -03:00
Daniel Hahler
4630e2725e Use TYPE_CHECKING instead of False
This allows for e.g. Jedi to infer types (it checks the name).

It was only used to support Python 3.5.0/3.5.1, where this is is not
available in the `typing` module.

Ref: https://github.com/davidhalter/jedi/issues/1472

Uses `TYPE_CHECKING = False` in `_pytest.outcomes` to avoid having to
work around circular import.
2020-01-16 16:11:39 +01:00
Daniel Hahler
ea31649062 ci: github actions: only deploy pytest-dev/pytest 2020-01-16 13:57:46 +01:00
Bruno Oliveira
3789bb53a7 junit_logging options (follow up to #6469) (#6473)
junit_logging options (follow up to #6469)
2020-01-16 08:13:48 -03:00
Bruno Oliveira
9298f7e4a9 Improve CHANGELOG and docs for junit_logging 2020-01-16 07:47:00 -03:00
Bruno Oliveira
715f56dfbc Fixtures now register finalizers with all fixtures before them… (#6438)
Fixtures now register finalizers with all fixtures before them in the stack
2020-01-16 07:33:55 -03:00
Jakub Mitoraj
ab6406b42e Update junit_logging with no,log,system-out,system-err,out-err,all 2020-01-16 08:14:46 +01:00
Chris NeJame
99180939fe fixtures register finalizers with all fixtures before them in the stack 2020-01-15 11:00:42 -05:00
Bruno Oliveira
1ec5befdb7 Merge pull request #6468 from nicoddemus/deploy-release-notes-6369
Add deploy step: publish package and release notes
2020-01-15 09:05:23 -03:00
Ronny Pfannschmidt
8ba0b7bc2a fix #6341 - disallow session/config in Node.from_parent 2020-01-15 13:00:46 +01:00
Bruno Oliveira
1d3f27cef0 Add deploy step: publish package and release notes
Fix #6369
2020-01-15 08:11:35 -03:00
Daniel Hahler
29703a5f51 Merge pull request #6466 from blueyed/cover-safe_getattr
tests: cover safe_getattr
2020-01-15 11:20:42 +01:00
Daniel Hahler
6f7a95c32e tests: cover safe_getattr 2020-01-15 11:20:00 +01:00
Daniel Hahler
bebfd28da3 doc: revisit section about rootdir
Ref: https://github.com/pytest-dev/pytest/issues/6376
2020-01-15 09:43:35 +01:00
Daniel Hahler
f5844449a8 Merge pull request #6442 from blueyed/rP
terminal: summary_passes: handle teardown sections
2020-01-15 03:02:09 +01:00
Bruno Oliveira
f2659f77be Merge master into features (#6458)
Merge master into features
2020-01-14 20:06:51 -03:00
Bruno Oliveira
b9c136b809 Use a dummy RemoteTraceback for test in Python 3.5 Windows
Somehow in Python 3.5 on Windows this test fails with:
   File "c:\hostedtoolcache\windows\python\3.5.4\x64\Lib\multiprocessing\connection.py", line 302, in _recv_bytes
     overlapped=True)
OSError: [WinError 6] The handle is invalid

This only happens in this platform and Python version, decided to use
a dummy traceback as originally done in #6412.
2020-01-14 18:31:21 -03:00
Pauli Virtanen
fd1691a2b3 Make --showlocals work together with --tb=short
Enable showing local variables when asked to do so in the short
traceback mode.

Fixes #494
2020-01-14 21:30:58 +02:00
Daniel Hahler
4a265ba38b Merge pull request #6446 from blueyed/tox-mypy
tox: add mypy toxenv
2020-01-14 18:26:35 +01:00
Daniel Hahler
910d5df6a8 Merge pull request #6456 from blueyed/fix-doc-_splitnode
minor: fix doc/example for _pytest.nodes._splitnode
2020-01-14 15:22:01 +01:00
Bruno Oliveira
21d189eb52 Enable GitHub actions for 'features' 2020-01-14 09:18:34 -03:00
Bruno Oliveira
e9d9f71374 Merge remote-tracking branch 'upstream/master' into mm 2020-01-14 09:17:52 -03:00
Bruno Oliveira
00adb4e42f Implement code coverage in GitHub actions (#6441)
Implement code coverage in GitHub actions
2020-01-14 09:14:57 -03:00
Daniel Hahler
b2cb87fae6 Merge pull request #6440 from blueyed/py351
ci: Travis: Python 3.5.1 via Trusty
2020-01-14 12:41:16 +01:00
Daniel Hahler
189fe3ba1d minor: fix doc/example for _pytest.nodes._splitnode 2020-01-14 12:40:36 +01:00
Bruno Oliveira
d291905825 Append token to codecov.yml instead of duplicating the file 2020-01-14 07:47:21 -03:00
Daniel Hahler
f0c7f21312 Remove "pragma: no cover" comments 2020-01-14 09:15:36 +01:00
Daniel Hahler
4ff7453b48 ci: Travis: Python 3.5.1 via Trusty
Python 3.5.0 caused flaky failures before
(https://github.com/pytest-dev/pytest/issues/5795).

This is pulled out of https://github.com/pytest-dev/pytest/pull/6435,
which adds code specific for Python < 3.5.2.

It only runs a specific test, while collecting everything to get
coverage of the version specific code around typing.
2020-01-14 09:15:36 +01:00
Daniel Hahler
0e70acab79 tox: add mypy toxenv
This is different from what pre-commit (in "linting") runs in that it
uses stubs from (test) dependencies.

It would make sense to run this on CI additionally (since there is no
"pre-commit --skip mypy", and a separate config is not worth it).
But currently it triggers a false positive though anyway
(https://github.com/erikrose/more-itertools/pull/374).
2020-01-14 08:59:48 +01:00
Daniel Hahler
8eec42f040 Merge pull request #6455 from blueyed/mypy-master
master: update mypy 0.740 -> 0.761
2020-01-14 08:56:51 +01:00
Daniel Hahler
3adaa3d87b Merge pull request #6447 from blueyed/fix-determine_setup
typing: fix _pytest.config.findpaths.determine_setup
2020-01-14 08:56:28 +01:00
Ran Benita
090e260517 master: update mypy 0.740 -> 0.761
(cherry picked from commit 16ff9f591e)
(cherry picked from commit 4848bbdf9a)
2020-01-14 06:31:41 +01:00
Daniel Hahler
117072d64c typing: fix _pytest.config.findpaths.determine_setup 2020-01-13 11:45:20 +01:00
Daniel Hahler
90740007a8 Merge pull request #6445 from blueyed/tox-pre-commit-posargs
tox: linting: pass posargs
2020-01-12 21:17:14 +01:00
Daniel Hahler
5e1c6ce630 tox: linting: pass posargs 2020-01-12 20:09:51 +01:00
Daniel Hahler
a136111dcc tests: test_xfail_handling: use sys.dont_write_bytecode 2020-01-11 23:05:12 +01:00
Daniel Hahler
61d04d3084 terminal: summary_passes: handle teardown sections
Fixes https://github.com/pytest-dev/pytest/issues/2780.
2020-01-11 21:58:19 +01:00
Bruno Oliveira
a3bc6df950 Implement code coverage in GitHub actions
This overwrites the `codecov.yml` file in the root of the repository with
`codecov-upstream.yml` file (which contains the code-cov token)´, so PRs
and branches on the repository can upload coverage.

Suggestion from here:

https://github.com/pytest-dev/pytest/pull/6421#issuecomment-571934112

Security concerns: the token might be misused, but only to upload bogus coverage
to `codecov.io`, so the team believe this is harmless. If we decide to fallback
from this decision , we just need to revoke the token.

Related to #6369
2020-01-11 12:21:20 -03:00
Daniel Hahler
2d488f7615 Merge pull request #6432 from blueyed/merge-master-into-features
Merge master into features
2020-01-10 14:44:30 +01:00
Daniel Hahler
1356d20e90 Merge master into features 2020-01-10 05:20:41 +01:00
Bruno Oliveira
622995a501 Fix grammar in README (#6427)
Fix grammar in README
2020-01-09 20:22:05 -03:00
Daniel Hahler
1e28cb855d Merge pull request #6425 from blueyed/xfail-yellow
terminal: use "yellow" with any "xpassed" tests
2020-01-09 23:22:58 +01:00
Ryan Barner
36531599a4 Fix grammar in README
Corrects grammar error in "Support pytest" section.
2020-01-09 14:12:57 -08:00
Bruno Oliveira
29db2da9a7 tmpdir_factory.mktemp now fails given absolute and non-normaliz… (#6323)
tmpdir_factory.mktemp now fails given absolute and non-normalized paths.
2020-01-09 19:10:03 -03:00
Bruno Oliveira
24f8002de8 Fix wrong 'changelog' and 'reference' links in docs (#6424)
Fix wrong 'changelog' and 'reference' links in docs
2020-01-09 19:09:35 -03:00
Bruno Oliveira
5b295ec68e Merge remote-tracking branch 'upstream/features' into gftea/features 2020-01-09 18:41:47 -03:00
Bruno Oliveira
fa645a7003 Improve docstrings for mktemp 2020-01-09 18:20:46 -03:00
Daniel Hahler
13baab746d terminal: use "yellow" with any "xpassed" tests
Closes https://github.com/pytest-dev/pytest/issues/449.
2020-01-09 22:20:41 +01:00
Daniel Hahler
9f1ade9acf Merge pull request #6411 from blueyed/cacheprovider-copy-items
cacheprovider: pytest_collection_modifyitems: copy items
2020-01-09 22:07:20 +01:00
Bruno Oliveira
23475b6ab9 Fix wrong 'changelog' and 'reference' links in docs
Both references were referencing links from Python because of our intersphinx
mapping in `conf.py`:

    intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}

Because Python's docs explicitly define both references, Sphinx fallbacks to
them instead of generating implicit references as was expected.

Fix #6397
2020-01-09 18:06:15 -03:00
Daniel Hahler
2d2c67d7c0 cacheprovider: pytest_collection_modifyitems: copy items 2020-01-09 21:48:54 +01:00
Anthony Sottile
cff7843f3b Merge pull request #6412 from nicoddemus/remote-tb-5971
Fix serialization of 'None' reprcrashes
2020-01-07 11:08:28 -05:00
Bruno Oliveira
356d865ad7 Use concurrent.futures for fidelity to the original report
As requested in review
2020-01-07 12:45:18 -03:00
Bruno Oliveira
f46ad8d114 Unifying black version in pre-commit config file (#6413)
Unifying black version in pre-commit config file
2020-01-07 09:07:47 -03:00
Marcelo Duarte Trevisani
8dbf6a4b2d Unifying black version 2020-01-07 11:07:05 +00:00
Bruno Oliveira
0e00069340 Fix serialization of 'None' reprcrashes
Tracebacks coming from remote processes crated by the multiprocess module
will contain "RemoteTracebacks" which don't have a 'reprcrash' attribute

Fix #5971
2020-01-06 22:04:38 -03:00
Bruno Oliveira
e8c8559efa Remove usage of parser module (deprecated in Python 3.9) (#6407)
Remove usage of parser module (deprecated in Python 3.9)
2020-01-06 13:07:56 -03:00
Bruno Oliveira
91a96ec3d6 Remove usage of parser module, deprecated in Python 3.9
Fix #6404
2020-01-06 08:57:07 -03:00
Bruno Oliveira
12f74a28fa Revert "Remove unused _pytest.code.Source.isparseable function"
This reverts commit c627ac4e59.
2020-01-05 14:12:40 -03:00
Bruno Oliveira
0fa35960ba Remove unused _pytest.code.Source.isparseable function (#6405)
Remove unused _pytest.code.Source.isparseable function
2020-01-05 12:52:23 -03:00
Bruno Oliveira
c627ac4e59 Remove unused _pytest.code.Source.isparseable function
Besides unused, it uses the (deprecated in Python 3.9) parser module

Fix #6404
2020-01-05 12:33:12 -03:00
Anthony Sottile
26a2e1aba7 Merge pull request #6401 from nicoddemus/4.6-maintenance-docs-onward
Update py27/py34 deprecation docs
2020-01-04 16:24:56 -05:00
Bruno Oliveira
7c80335c6b Merge pull request #6391 from asottile/release-4.6.9 (#6403)
Merge pull request #6391 from asottile/release-4.6.9
2020-01-04 18:13:56 -03:00
Anthony Sottile
75f964c08d Merge pull request #6391 from asottile/release-4.6.9
Preparing release version 4.6.9
2020-01-04 13:01:46 -08:00
Bruno Oliveira
4fa819e535 Update py27/py34 deprecation docs
I've updated the text and incorporated the topics from #5275, so this
can now be part of the official docs, and #5275 can be closed/unpinned.

Closes #5275
2020-01-04 17:52:02 -03:00
Bruno Oliveira
61061d2147 Update copyright year to 2020 (#6400)
Update copyright year to 2020
2020-01-04 09:41:53 -03:00
Bruno Oliveira
deb4287d1c Update copyright year to 2020
Merge pull request #6392 from hugovk/4.6-maintenance-2020
2020-01-04 08:46:58 -03:00
Daniel Hahler
7aac48c418 Merge pull request #6382 from blueyed/fix-parseoutcomes
Fix `RunResult.parseoutcomes` (follow-up to #6353)
2020-01-04 00:49:24 +01:00
Ran Benita
0375c1b728 Merge pull request #6388 from bluetech/mypy-761
Update mypy 0.750 -> 0.761
2020-01-01 16:07:55 +02:00
Ran Benita
4848bbdf9a Update mypy 0.750 -> 0.761
This fixes some type: ignores due to typeshed update.

Newer mypy seem to ignore unannotated functions better, so add a few
minor annotations so that existing correct type:ignores make sense.
2020-01-01 15:22:16 +02:00
Daniel Hahler
8656c1a61d Merge pull request #6381 from blueyed/fix-revert-formatting
Revert black formatting of essential_plugins
2020-01-01 14:16:35 +01:00
Daniel Hahler
3b60e36dbb Merge pull request #6380 from blueyed/doc
minor: split doc with _early_rewrite_bailout
2020-01-01 14:16:22 +01:00
Anthony Sottile
162d737f68 Merge pull request #6385 from betchern0t/master
Added how to reserve an issue to yourself when contributing
2019-12-31 11:53:50 -05:00
PaulC
d884164160 removed trailing whitespace to fix linting issue 2019-12-31 12:49:37 +11:00
PaulC
9811ebdc57 Added how to reserve an issue to yourself when contributing 2019-12-31 10:32:31 +11:00
Daniel Hahler
1c0242dec1 Fix RunResult.parseoutcomes (follow-up to #6353) 2019-12-30 17:08:52 +01:00
Daniel Hahler
a5224f7490 Revert black formatting of essential_plugins
Done in a02310a140 (likely automatic), but loses information of the
comment obviously.
2019-12-30 15:28:37 +01:00
Daniel Hahler
a5863ca760 minor: split doc with _early_rewrite_bailout 2019-12-30 09:41:36 +01:00
Bruno Oliveira
8077168387 pytester: quick fix error introduced in #5990 (#6353)
pytester: quick fix error introduced in #5990
2019-12-27 13:28:11 -03:00
Bruno Oliveira
afa899d5e1 Azure Pipelines: Test on Python 3.8 (#6159)
Azure Pipelines: Test on Python 3.8
2019-12-27 13:27:17 -03:00
Hugo
8de9b1be56 Test on Python 3.8 2019-12-27 13:10:43 -03:00
Bruno Oliveira
b532d15fe7 Improve warnings docs (#6366)
Improve warnings docs
2019-12-26 19:52:15 -03:00
Adam Johnson
73702ca88b Improve warnings docs
* Rearrange section about context manager to be in order
* Link to `pytest.warns` and `recwarn` since a reader going top to bottom won't have seen about those yet.
* Used only context manager form in the example; the call form is somewhat obsolete
  and is mentioned in the reference docs already.
* Reuse the 'myfunction' from first example on the second one

Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
2019-12-26 19:16:19 -03:00
Anthony Sottile
d7b0389d1a Merge pull request #6347 from noviluni/delete_deprecated_function
delete inspect.getargspect() as is deprecated since Python 3.0
2019-12-26 13:45:46 -05:00
Bruno Oliveira
06206bcf37 Merge pull request #6355 from nicoddemus/add-gh-actions
Add GitHub actions for CI
2019-12-26 13:32:17 -03:00
Bruno Oliveira
466bbbf8e8 invocation in last section 'pythonpath.rst' title swapped (#6357)
invocation in last section 'pythonpath.rst' title swapped
2019-12-26 08:55:55 -03:00
Bruno Oliveira
a9608d54e0 Switch the order of the commands back and update the text
As suggested during review
2019-12-26 08:19:11 -03:00
Bruno Oliveira
9924432a2e Improve docs so regen doesn't leak temp directories (#6364)
Improve docs so regen doesn't leak temp directories
2019-12-21 13:23:08 -03:00
Bruno Oliveira
c7ac3379e7 Update release notes script after CHANGELOG changed location (#6362)
Update release notes script after CHANGELOG changed location
2019-12-21 13:22:42 -03:00
Anthony Sottile
6cd61390c2 Improve docs so regen doesn't leak temp directories 2019-12-20 13:18:49 -08:00
Bruno Oliveira
994909270f Update release notes script after CHANGELOG changed location 2019-12-20 08:54:44 -03:00
Bruno Oliveira
e1df9dbf0d Merge pull request #6360 from asottile/release-4.6.8 (#6361)
Merge pull request #6360 from asottile/release-4.6.8
2019-12-19 22:46:55 -03:00
Anthony Sottile
ab44d3d733 Merge pull request #6360 from asottile/release-4.6.8
Preparing release version 4.6.8
2019-12-19 16:01:04 -08:00
Bruno Oliveira
d76aa8b428 Add GitHub actions for CI
This includes our current full matrix (windows, linux and macos), for evaluting
purposes.

We should disconsider failures when evaluating PRs.

TODO:

- deploy
- coverage
- github release notes

Even with the above missing, I still believe it would be nice to merge
this and have GitHub actions working in parallel so we can evaluate performance
and usability from now on.
2019-12-19 11:06:57 -03:00
Bruno Oliveira
4dfd2947bc fix typos in docs (#6356)
fix typos in docs
2019-12-19 09:31:08 -03:00
captainCapitalism
ed57b8e08a invocation in last section 'pythonpath.rst' title swapped
The order of invocations 'python -m pytest' and 'pytest' are different in the header and the explanation. Me being lazy reading about the behaviour of 'former' looked up quickly the title and rushed to implementation to discover it actually works the other way - as stated in the documentation. So I propose to switch the order in the title to achieve consistent ordering and not confusing somebody like me again! :)
2019-12-19 11:35:52 +01:00
marc
536177bb56 fix typos in docs 2019-12-19 10:35:15 +01:00
Alexandre Mulatinho
dc7bf518b3 pytester: quick fix error introduced in #5990
- added a test to check this condition

Signed-off-by: Alexandre Mulatinho <alex@mulatinho.net>
2019-12-18 16:36:24 -03:00
Bruno Oliveira
75493f78bf Merge master into features (#6346)
Merge master into features
2019-12-16 21:57:26 -03:00
Bruno Oliveira
c487cf9dd5 Deprecate no print logs (#6333)
Deprecate no print logs
2019-12-16 19:01:16 -03:00
Bruno Oliveira
8be9684ab2 Optimized renaming of test parameter ids (#6350)
Optimized renaming of test parameter ids
2019-12-16 18:54:35 -03:00
Seth Junot
d4879c7afb Optimized renaming of test parameter ids
While using pytest-repeat, I noticed the previous implementation is slow
for a large number of duplicate test ids. To optimize, this commit
reduces the amount of data copied and avoids using `in` with List
(unhashable type, and therefore is very slow for many elements).
2019-12-16 18:53:48 -03:00
Vinay Calastry
afbaee7649 Deprecate --no-print-logs option 2019-12-14 16:46:30 -08:00
marc
d42f5a41a5 delete inspect.getargspect() as is deprecated since Python 3.0 2019-12-14 19:52:17 +01:00
Bruno Oliveira
853889e5db Merge remote-tracking branch 'upstream/master' into mm 2019-12-14 10:45:44 -03:00
Bruno Oliveira
a176ff77bc Release 5.3.2 (#6342)
Release 5.3.2
2019-12-14 10:39:19 -03:00
Bruno Oliveira
7f24cc2feb Remove duplicated user from announcement 2019-12-14 10:06:59 -03:00
Bruno Oliveira
d0c663a628 Improve warning about incoming change to 'junitxml_family' defa… (#6343)
Improve warning about incoming change to 'junitxml_family' default
2019-12-13 12:57:21 -03:00
Bruno Oliveira
f7409f8685 Improve warning about incoming change to 'junitxml_family' default
Fix #6265
2019-12-13 09:17:12 -03:00
Bruno Oliveira
10fcac7f90 Preparing release version 5.3.2 2019-12-13 08:51:15 -03:00
Bruno Oliveira
8942a05cfe Change 4639 from feature to improvement
An improvement seems more adequate here.
2019-12-13 08:46:47 -03:00
Bruno Oliveira
ecd1e43afb Make 'S' and 'F' aliases to 's' and 'f' respectively (#6337)
Make 'S' and 'F' aliases to 's' and 'f' respectively
2019-12-13 07:47:48 -03:00
Bruno Oliveira
66c1a120ba Bugfix 5430 pass logs to junit report (#6274)
Bugfix 5430 pass logs to junit report
2019-12-12 09:35:25 -03:00
gftea
226f0c48bf fix #5686, mktemp now fails given absolute and non-normalized paths. 2019-12-12 13:00:23 +01:00
Bruno Oliveira
9b74bf1e0c Add CHANGELOG entry for #6334 2019-12-12 08:05:22 -03:00
Bruno Oliveira
fa51a26743 Make -r letters "s" and "S" aliases
Similar reasons as the previous commit
2019-12-12 07:48:07 -03:00
Bruno Oliveira
59067ad33d Make -r letters "f" and "F" aliases
As far as the output is concerned, they are both identical so it doesn't
make sense to have both.

setup, teardown, and collect failures are already reported as "errors", "E".
2019-12-12 07:43:37 -03:00
Bruno Oliveira
cbb2f9541b Merge pull request #6316 from cb109/make-keyword-expression-matching-case-insensitive
Make keyword expression matching case-insensitive
2019-12-12 06:47:59 -03:00
Anthony Sottile
b29ae03cb6 Merge pull request #6329 from nicoddemus/4639-improv
Change 4639 from feature to improvement
2019-12-11 13:13:31 -08:00
Bruno Oliveira
0711060422 Change 4639 from feature to improvement
An improvement seems more adequate here.
2019-12-09 15:57:19 -03:00
Bruno Oliveira
1ef29ab548 #4597: tee-stdio capture method (#6315)
#4597: tee-stdio capture method
2019-12-09 15:55:17 -03:00
cmachalo
e13ad22364 Include new --capture-mode=tee-sys option
Fix #4597
2019-12-09 13:05:23 -03:00
Zac Hatfield-Dodds
8cdf9d43a9 Fixes #6326: Typo in the Security section docs home page. (#6327)
Fixes #6326: Typo in the Security section docs home page.
2019-12-09 17:28:06 +11:00
Michael Rose
2ddc330b62 Fixes #6326: Typo in the Security section docs home page. 2019-12-08 22:26:53 -05:00
Ronny Pfannschmidt
30f2729684 Merge pull request #6298 from RonnyPfannschmidt/deprecation-breakage
Deprecation policy - insert considerations for breaking changes
2019-12-07 19:50:44 +01:00
Ronny Pfannschmidt
3812985ed4 update backward compatibility policy to allow for breakage
Co-Authored-By: Anthony Sottile <asottile@umich.edu>
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
2019-12-07 18:59:21 +01:00
Bruno Oliveira
c6ed69a666 Replace 'removal' by 'breaking' changelog category
As discussed, sometimes we will need to introduce changes
which are not necessarily removals but might break existing
suites
2019-12-06 08:50:35 -03:00
Christoph Bülter
3a0f436c1a Iterate a generator expression instead of a temporary list
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2019-12-06 08:40:49 +01:00
Bruno Oliveira
1c0ab3c2a3 Add 4.6.7 changelog to master (Wait until #6318) (#6319)
Add 4.6.7 changelog to master (Wait until #6318)
2019-12-05 22:45:12 -03:00
Anthony Sottile
7ff91d8127 Merge pull request #6313 from nicoddemus/egg-rewrite-6301
Fix assertion rewriting module detection for egg dists
2019-12-05 16:24:13 -08:00
Bruno Oliveira
64c71daa21 Add 4.6.7 changelog to master 2019-12-05 17:32:45 -03:00
Christoph Buelter
a326fa22c6 Add a failing test to ensure not everything matches by accident 2019-12-05 17:02:48 +01:00
Christoph Bülter
623b3982b0 Update doc/en/example/markers.rst
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2019-12-05 16:59:08 +01:00
Christoph Buelter
5a7de2c2cb Add changelog file for PR 6316 2019-12-05 14:28:21 +01:00
Christoph Buelter
24d4882d82 Update authors file and sort the list 2019-12-05 14:20:07 +01:00
Christoph Buelter
ac5929eef3 Update docs about case-insensitive expression matching 2019-12-05 14:13:22 +01:00
Christoph Buelter
e24b6b0388 Change -k EXPRESSION matching to be case-insensitive 2019-12-05 14:03:10 +01:00
Bruno Oliveira
c7f9fda42d Fix assertion rewriting module detection for egg dists
Fix #6301
2019-12-04 15:30:45 -03:00
Bruno Oliveira
985ac09048 Merge master into features (#6312)
Merge master into features
2019-12-03 13:36:58 -03:00
Bruno Oliveira
1c4a672a52 unittest: do not use TestCase.debug() with --pdb (#5996)
unittest: do not use TestCase.debug() with `--pdb`
2019-12-03 11:15:06 -03:00
Bruno Oliveira
59f95b7f59 Merge remote-tracking branch 'upstream/master' into mm 2019-12-03 11:07:34 -03:00
Bruno Oliveira
41b7b109e9 Merge branch 'features' into unittest-debug 2019-12-03 10:52:53 -03:00
Ran Benita
42fb1f7ede Merge pull request #6309 from jaredvasquez/fix-cafd-docs
Fix typo in documentation of capfd fixture
2019-12-03 12:15:40 +02:00
Ran Benita
c9ec724886 Merge pull request #6307 from bluetech/mypy-750
Update mypy 0.740 -> 0.750
2019-12-03 12:14:19 +02:00
Jared Vasquez
c00a43a17d fix typo 2019-12-02 22:29:22 -08:00
Bruno Oliveira
1dc612f7d4 Merge pull request #6304 from nicoddemus/pytest-as-pkg
Convert pytest.py into a package
2019-12-02 21:10:15 -03:00
Bruno Oliveira
e5bd7fb053 Convert pytest.py into a package
As discussed in https://github.com/pytest-dev/pytest/issues/3342, this
is the first step to make pytest support static typing fully
2019-12-02 19:27:11 -03:00
Bruno Oliveira
256a9e0027 Remove outdated py2py3 example (#6306)
Remove outdated py2py3 example
2019-12-02 16:54:12 -03:00
Ran Benita
16ff9f591e Update mypy 0.740 -> 0.750
Release notes:
https://mypy-lang.blogspot.com/2019/11/mypy-0.html
2019-12-02 21:52:11 +02:00
Ran Benita
d2d7b97a70 Remove outdated py2py3 example 2019-12-02 21:16:15 +02:00
Bruno Oliveira
23f6adc760 Ensure cache supporting files still exist after --cache-clear (#6296)
Ensure cache supporting files still exist after --cache-clear
2019-12-01 10:37:22 -03:00
Bruno Oliveira
172b82875a Ensure cache supporting files still exist after --cache-clear
Fix #6290
2019-12-01 10:36:47 -03:00
Bruno Oliveira
277857b026 docs: move changelog to docs/en and allow sphinx directives (#6287)
docs: move changelog to docs/en and allow sphinx directives
2019-11-29 10:51:01 -03:00
Daniel Hahler
d3ab56f531 docs: move changelog to docs/en and allow sphinx directives
Now `tox -e docs` will also include the draft changelog for the
next version (locally only).

`CHANGELOG.rst` now only points to the changelog on READTHEDOCS so
sphinx diretives can be used.

Followup to https://github.com/pytest-dev/pytest/pull/6272
2019-11-28 21:23:58 -03:00
Bruno Oliveira
da091b832d rename test_pdb to test_debugging (#6282)
rename test_pdb to test_debugging
2019-11-27 09:08:02 -03:00
Ronny Pfannschmidt
8feeb09398 fixes #5065 2019-11-27 11:25:23 +01:00
Anthony Sottile
209d99102d Merge pull request #6234 from asottile/remove_none_warning
Revert "A warning is now issued when assertions are made for `None`"
2019-11-26 13:04:42 -08:00
Ronny Pfannschmidt
6d31684da5 Merge pull request #6279 from nicoddemus/fix-changelog
Remove duplicated changelog entry for 5.3.1
2019-11-26 19:22:07 +01:00
Bruno Oliveira
4ee280ae1f Remove duplicated changelog entry for 5.3.1 2019-11-26 12:01:12 -03:00
Bruno Oliveira
8b8cba369c Preparing release version 5.3.1 (#6277)
Preparing release version 5.3.1
2019-11-26 11:56:56 -03:00
Daniel Hahler
b6b0bc03f3 Merge pull request #6164 from blueyed/pytester-no-color
pytester: use no colors with inline runs by default
2019-11-26 03:30:45 +01:00
Daniel Hahler
a1219ab8fc pytester: use no colors with inline runs by default
Sets `PY_COLORS=0` in the environment by default, which is used by pylib.

Via https://github.com/blueyed/pytest/pull/58

(initially cherry picked from commit f153ad33d10)
2019-11-25 23:48:11 +01:00
Bruno Oliveira
05008f6b55 Preparing release version 5.3.1 2019-11-25 14:32:37 -03:00
Claudio Madotto
83182b82ea Merge branch 'bugfix-5430-pass-logs-to-junit-report' of https://github.com/zupermanzupereroe/pytest into bugfix-5430-pass-logs-to-junit-report 2019-11-25 13:00:04 +01:00
Claudio Madotto
31d5cedc6d Avoid duplicating system-out and system-error tags 2019-11-25 12:59:03 +01:00
Claudio Madotto
91b3ff1bb7 Create changelog file and update AUTHORS 2019-11-25 12:59:03 +01:00
Claudio Madotto
b66dc80008 Fix for issue #5430 - junit-xml: logs are not passed to junit report for tests failed not in a teardown phase 2019-11-25 12:59:03 +01:00
zupermanzupereroe
69ad2026f6 Merge pull request #1 from pytest-dev/master
Update repository
2019-11-25 12:56:54 +01:00
Anthony Sottile
9d900930db Merge pull request #6242 from nicoddemus/testdir-changelog
Add link to testdir fixture in CHANGELOG entry
2019-11-24 17:23:02 -08:00
Daniel Hahler
47ae1fb36b Merge pull request #6271 from blueyed/typing
typing: minor improvements
2019-11-25 01:49:34 +01:00
Daniel Hahler
a8230d77f4 Merge pull request #6270 from blueyed/docs-log_cli
docs: add missing `log_cli` confval
2019-11-24 23:21:49 +01:00
Daniel Hahler
b7d908f4a5 Merge pull request #6269 from blueyed/docs
tox: docs: --keep-going and posargs
2019-11-24 23:21:26 +01:00
Daniel Hahler
bc7282576f typing: minor improvements 2019-11-24 23:20:03 +01:00
Daniel Hahler
b9dd0e6210 docs: add missing log_cli confval 2019-11-24 22:34:15 +01:00
Daniel Hahler
57f3dc19b9 tox: docs: --keep-going and posargs
`--keep-going` makes sense with `-W` to see all warnings/errors.

`{posargs:}` is useful for passing in custom args.
2019-11-24 22:21:08 +01:00
Daniel Hahler
d7d5cf4136 Merge pull request #6215 from blueyed/cleanup-exc
_idval: remove trailing newline from exception
2019-11-24 20:29:46 +01:00
Florian Bruhin
ed67312bca Merge pull request #6268 from felixonmars/patch-2
Correct a typo in _pytest/config/__init__.py
2019-11-24 17:04:26 +01:00
Claudio Madotto
2d24c062b6 Avoid duplicating system-out and system-error tags 2019-11-24 16:33:17 +01:00
Claudio Madotto
d940d0b657 Create changelog file and update AUTHORS 2019-11-24 16:08:45 +01:00
Claudio Madotto
f9f092a5e6 Fix for issue #5430 - junit-xml: logs are not passed to junit report for tests failed not in a teardown phase 2019-11-24 15:20:02 +01:00
Felix Yan
b7bc52f770 Correct a typo in _pytest/config/__init__.py 2019-11-24 20:28:10 +08:00
Bruno Oliveira
a3c8246b60 Node from parent (#5975)
Node from parent
2019-11-23 20:34:48 -03:00
Ronny Pfannschmidt
15ffe63204 update doc examples **untested** 2019-11-23 21:54:11 +01:00
Ronny Pfannschmidt
c99c7d0f95 deprecate direct node construction and introduce Node.from_parent 2019-11-23 21:54:11 +01:00
Bruno Oliveira
886b8d27c6 Merge pull request #5984 from phloose/acceptance-tests_pytest-dev/pytest/#4445
Add acceptance tests for "config warnings" stacklevel (#4445)
2019-11-22 19:45:41 -03:00
Daniel Hahler
d1eb89d694 Merge pull request #6086 from kondratyev-nv/master
Fix line detection for properties in doctest tests
2019-11-22 23:09:10 +01:00
Daniel Hahler
a4408eb9c1 Merge pull request #6219 from blueyed/testdir-use-monkeypatch
pytester: remove special handling of env during inner runs
2019-11-22 22:41:48 +01:00
Daniel Hahler
b0ebcfb785 pytester: remove special handling of env during inner runs
Closes https://github.com/pytest-dev/pytest/issues/6213.
2019-11-22 21:50:31 +01:00
Nikolay Kondratyev
5e097970df Fix line detection for properties in doctest tests
Co-Authored-By: Daniel Hahler <github@thequod.de>
2019-11-22 23:50:20 +03:00
Philipp Loose
a02310a140 Add stacklevel tests for warnings, 'location' to pytest_warning_captured
Resolves #4445 and #5928 (thanks to allanlewis)

Add CHANGELOG for location parameter
2019-11-22 17:50:00 -03:00
Daniel Hahler
0601f5cdad Merge pull request #6261 from blueyed/stats-keys
terminal: _get_main_color: help pytest-parallel
2019-11-22 17:12:33 +01:00
Daniel Hahler
a7268aaa5d Merge pull request #6258 from blueyed/notify_exception-handle-exit-exc-upstream
main: wrap_session: handle exit.Exception with notify_exception
2019-11-22 05:49:04 +01:00
Daniel Hahler
1f736a663d terminal: _get_main_color: help pytest-parallel
Use `dict.keys()` to work around `__iter__` not working with a
multiprocessing DictProxy.

Ref: https://github.com/python/cpython/pull/17333
Fixes https://github.com/pytest-dev/pytest/issues/6254.
Ref: https://github.com/browsertron/pytest-parallel/issues/36
2019-11-22 05:48:10 +01:00
Daniel Hahler
2344982d7f main: wrap_session: handle exit.Exception with notify_exception
Fixes https://github.com/pytest-dev/pytest/issues/6257.
Via https://github.com/blueyed/pytest/pull/132.
2019-11-21 22:50:33 +01:00
Daniel Hahler
2fa0518e89 Merge pull request #6259 from blueyed/merge-master-into-features
Merge master into features
2019-11-21 22:48:53 +01:00
Daniel Hahler
df0c652333 Merge master into features 2019-11-21 20:31:52 +01:00
Daniel Hahler
63c9ad02f4 Merge pull request #6252 from blueyed/minor-changelog
CHANGELOG: two minor fixes/improvements
2019-11-21 18:44:41 +01:00
Daniel Hahler
8b7aeefd7d Merge pull request #6248 from blueyed/default-role
docs: configure default_role=literal
2019-11-21 18:44:17 +01:00
Bruno Oliveira
f1ac0eeef0 Remove sys.last_traceback attribute using del instead of settin… (#6256)
Remove sys.last_traceback attribute using del instead of setting to None
2019-11-21 11:16:19 -03:00
Mark Dickinson
82424c9270 Fix reST markup. 2019-11-21 13:37:17 +00:00
Mark Dickinson
dbb8c146f0 Use proper reST attribute markup. 2019-11-21 13:22:34 +00:00
Mark Dickinson
8d686a8e46 Add self to AUTHORS 2019-11-21 13:14:19 +00:00
Mark Dickinson
9d1082bd30 Add changelog file. 2019-11-21 13:13:36 +00:00
Bruno Oliveira
490c7c7262 Add develop instructions to CONTRIBUTING (#6249)
Add develop instructions to CONTRIBUTING
2019-11-21 10:07:00 -03:00
Mark Dickinson
2ffbe41ae5 clear sys.last_traceback via del instead of = None 2019-11-21 13:06:47 +00:00
Bruno Oliveira
8f2fd8ffc0 Add develop instructions to CONTRIBUTING
From: https://github.com/pytest-dev/pytest/pull/6244
2019-11-21 10:06:32 -03:00
Mark Dickinson
64eb9ea670 Modify test for new expected behaviour 2019-11-21 11:50:40 +00:00
Ran Benita
5820c5c5a6 Merge pull request #6241 from bluetech/type-annotations-9
Add type annotations to _pytest.config.argparsing and corresponding Config code
2019-11-21 13:33:13 +02:00
Zac Hatfield-Dodds
7e10c8191d Added link checking to tox and release.py (#5614)
Added link checking to tox and release.py
2019-11-21 16:46:13 +11:00
Daniel Hahler
6659fe0edc CHANGELOG: two minor fixes/improvements 2019-11-21 06:20:57 +01:00
Daniel Hahler
4ee984ff0a Merge pull request #6250 from blueyed/tbh
pytester: LineMatcher: __tracebackhide__ with _fail
2019-11-21 04:26:20 +01:00
Daniel Hahler
b96e0a71a6 pytester: LineMatcher: __tracebackhide__ with _fail
Follow-up to 2228ccb (gone lost in resolving the conflict).
2019-11-21 01:23:36 +01:00
Daniel Hahler
ed012c808a Merge pull request #6174 from blueyed/ids-iter
parametrized: ids: support generator/iterator
2019-11-21 00:37:25 +01:00
Daniel Hahler
be722652f0 docs: configure default_role=literal
This configures the default role for interpreted text (single
backticks), avoiding the need to check for / enforce double backticks.

Fixes also one instance in the existing changelog:

    - Detect `pytest_` prefixed hooks using the internal plugin manager since
      ``pluggy`` is deprecating the ``implprefix`` argument to ``PluginManager``.
      (`#3487 <https://github.com/pytest-dev/pytest/issues/3487>`_)
2019-11-21 00:35:00 +01:00
Daniel Hahler
6b75a7733b Merge pull request #6247 from blueyed/collecterror-fulltrace
Respect --fulltrace with collection errors
2019-11-21 00:27:23 +01:00
Daniel Hahler
2d449e95e4 Respect --fulltrace with collection errors 2019-11-20 23:35:33 +01:00
Ran Benita
dac16cd9e5 Add type annotations to _pytest.config.argparsing and corresponding Config code 2019-11-20 22:02:27 +02:00
Daniel Hahler
2c941b5d13 parametrized: ids: support generator/iterator
Fixes https://github.com/pytest-dev/pytest/issues/759

- Adjust test_parametrized_ids_invalid_type, create list to convert tuples
  Ref: https://github.com/pytest-dev/pytest/issues/1857#issuecomment-552922498

- Changelog for int to str conversion
  Ref: https://github.com/pytest-dev/pytest/issues/1857#issuecomment-552932952
2019-11-20 19:02:17 +01:00
Daniel Hahler
98c899c9b0 Merge pull request #6245 from blueyed/tests-_idval
testing/python/metafunc.py: import _idval once
2019-11-20 19:00:39 +01:00
Daniel Hahler
58ec5bea35 Merge pull request #6237 from blueyed/fix-no_fnmatch_line
pytester: reset log output in _match_lines
2019-11-20 18:44:37 +01:00
Daniel Hahler
f1224a0e85 Merge pull request #6243 from blueyed/move-_pformat_dispatch
minor: move internal _pformat_dispatch function
2019-11-20 18:42:21 +01:00
Daniel Hahler
ccb3ef3b33 testing/python/metafunc.py: import _idval once 2019-11-20 18:02:30 +01:00
Daniel Hahler
c0b1a39192 minor: move internal _pformat_dispatch function 2019-11-20 17:57:14 +01:00
Bruno Oliveira
0be03d7fe4 Add link to testdir fixture in CHANGELOG entry
As per https://github.com/pytest-dev/pytest/pull/5914#issuecomment-556063975
2019-11-20 13:14:17 -03:00
Ran Benita
51f9cd0e02 argparsing: remove "map_long_option" Action attribute support
This feature was added in commit
007a77c2ba, but was never used in pytest
itself. A GitHub code search doesn't find any users either (only pytest
repo copies). It seems safe to clean up.
2019-11-20 17:09:24 +02:00
Bruno Oliveira
2879d25812 Fix rendering of Before/After in changelog (#6238)
Fix rendering of Before/After in changelog
2019-11-20 07:32:17 -03:00
Bruno Oliveira
fe69a2cfb7 Delete 5934.feature.rst included in the wrong folder by accident 2019-11-20 07:06:11 -03:00
Bruno Oliveira
af9dfc604d Introduce 5934 in CHANGELOG and fix "pytest" blocks 2019-11-20 07:05:31 -03:00
Anthony Sottile
8c65eae5f4 Fix rendering of Before/After in changelog
Apparently the version of sphinx that rtd uses is a little more strict about whether an anonymous `code-block` can happen
2019-11-19 21:12:30 -08:00
Daniel Hahler
2228ccbfb4 pytester: reset log output in _match_lines (#70)
This is necessary for when using e.g. `no_fnmatch_line` after it.
Factor it out into `_fail`.

(cherry picked from commit aade7ed0045ba32557ef8565cbab28a2c91053a7)

Ref: https://github.com/pytest-dev/pytest/pull/5914#issuecomment-549182242
2019-11-20 05:24:18 +01:00
Bruno Oliveira
7e5ad31428 Merge features into master after 5.3 (#6236)
Merge features into master after 5.3
2019-11-19 19:17:06 -03:00
Bruno Oliveira
688bbefed1 Improve instructions on how to write CHANGELOG entries (#6235)
Improve instructions on how to write CHANGELOG entries
2019-11-19 19:10:41 -03:00
Bruno Oliveira
5b3867fd65 Release 5.3.0 (#6233)
Release 5.3.0
2019-11-19 18:49:14 -03:00
Bruno Oliveira
36ef545b2d Improve instructions on how to write CHANGELOG entries
This makes easier for contributors to get the CHANGELOG entry
right the first time.
2019-11-19 14:15:55 -03:00
Daniel Hahler
1d368e0ed4 Merge pull request #6231 from blueyed/param-spell
Improve check for misspelling of parametrize
2019-11-19 17:57:28 +01:00
Bruno Oliveira
be59827216 Small fixes in the CHANGELOG for 5.3.0 2019-11-19 13:56:22 -03:00
Anthony Sottile
faea273c93 Revert "A warning is now issued when assertions are made for None" 2019-11-19 08:24:08 -08:00
Bruno Oliveira
4b16b93cf5 Preparing release version 5.3.0 2019-11-19 12:43:51 -03:00
Bruno Oliveira
21622d0df4 Merge remote-tracking branch 'upstream/master' into release-5.3.0 2019-11-19 12:42:11 -03:00
Daniel Hahler
4ad61cbcf6 Improve check for misspelling of parametrize
- there is no need to do this with `--strict-markers`
- it can be done when looking up marks, instead of for every generated
  test
2019-11-19 16:05:52 +01:00
Daniel Hahler
d1e2d12b3f python: remove unused pytest_make_parametrize_id hookimpl (#6228) 2019-11-19 02:55:24 +01:00
Bruno Oliveira
f36ea240fe Remove check for os.symlink, always there in py3+ (#6227)
Remove check for os.symlink, always there in py3+
2019-11-18 22:37:59 -03:00
Daniel Hahler
4804d4bc98 python: remove unused pytest_make_parametrize_id hookimpl
Added in 79927428d initially, but never used.
2019-11-19 02:27:53 +01:00
Daniel Hahler
b820b7e384 Merge pull request #6224 from blueyed/visit_Assert-minor-cleanup
minor: visit_Assert: move setting of `negation` out of branches
2019-11-19 01:11:53 +01:00
Daniel Hahler
8d3e8b1c54 Revert "ci: use tox -vv" (#6226) 2019-11-19 01:10:06 +01:00
Anthony Sottile
63a23d876c Remove check for os.symlink, always there in py3+ 2019-11-18 16:01:44 -08:00
Anthony Sottile
eeeb19626b Merge pull request #6202 from linw1995/fix_getmodpath
Fix incorrect result of getmodpath method.
2019-11-18 15:14:52 -08:00
Bruno Oliveira
bebd80456b Fix --setup-plan fixture lifetimes (#6214)
Fix --setup-plan fixture lifetimes
2019-11-18 20:04:17 -03:00
Daniel Hahler
f38f2d402e minor: visit_Assert: move setting of negation out of branches 2019-11-18 23:21:00 +01:00
Daniel Hahler
f9feef6808 Revert "ci: use tox -vv"
`tox -vv` is too verbose, and was only used as a hack to get the output
of durations.

As for information in logs `-v` could be used maybe still, but I've
decided to revert it for now.

This reverts commit 56cec5fa79.
2019-11-18 23:14:03 +01:00
Bruno Oliveira
89eeefbbaf Merge pull request #6192 from nicoddemus/remove-reportlog-6180
Remove report_log in favor of pytest-reportlog
2019-11-18 17:58:37 -03:00
Daniel Hahler
ed5f191da2 mypy: config: use mypy_path=src (#6222) 2019-11-18 21:51:39 +01:00
Daniel Hahler
b4ff6b3672 Metafunc: remove hack for DefinitionMock (#6223) 2019-11-18 19:56:00 +01:00
Daniel Hahler
2ad2fbc9a2 Metafunc: remove hack for DefinitionMock
Done initially in 99015bfc8.
2019-11-18 18:19:34 +01:00
Daniel Hahler
b461010f32 mypy: config: use mypy_path=src
This allows for checking files inside of "testing" without having
"src/…" as an argument also.
2019-11-18 18:12:59 +01:00
Daniel Hahler
64d8910516 Metafunc: remove unused _ids (#6220) 2019-11-18 18:00:29 +01:00
Daniel Hahler
b412661de9 Factor out _validate_parametrize_spelling (#6221) 2019-11-18 18:00:00 +01:00
林玮
5d5f480979 Hardening an existing test for demonstrating this change. 2019-11-18 23:46:38 +08:00
Daniel Hahler
91dec8e2bf Factor out _validate_parametrize_spelling
This makes it easier to read `pytest_generate_tests`.
2019-11-18 16:36:12 +01:00
Daniel Hahler
f3a10245d0 Metafunc: remove unused _ids
Forgotten in 40b85d7ee.
2019-11-18 16:21:13 +01:00
Daniel Hahler
426a4cdca9 _idval: remove trailing newline from exception 2019-11-18 01:10:00 +01:00
Josh Karpel
46ffdf0e3a Update AUTHORS 2019-11-17 17:17:47 -06:00
JoshKarpel
1e3be8ada4 fix whitespace issues in tests for #2049 2019-11-17 17:14:17 -06:00
JoshKarpel
6dfd683a0c changelog entry for #2049 2019-11-17 16:47:09 -06:00
JoshKarpel
9e759010d9 resolve #2049 2019-11-17 16:45:42 -06:00
Anthony Sottile
a2d48332fc Merge pull request #6201 from asottile/mm
Merge master into features
2019-11-17 11:30:51 -08:00
Daniel Hahler
bac6eebfff tests: revisit test_cacheprovider (#6199) 2019-11-17 19:23:16 +01:00
Ran Benita
fa578d7329 Merge pull request #6205 from bluetech/type-annotations-8
Add type annotations to _pytest.compat and _pytest._code.code
2019-11-17 09:45:32 +02:00
Daniel Hahler
b9a3ba1fe8 test_cache_writefail_permissions: ignore any other plugins 2019-11-16 23:29:24 +01:00
Daniel Hahler
1b4623a6d1 tests: revisit test_cacheprovider 2019-11-16 23:29:24 +01:00
Ran Benita
eaa34a9df0 Add type annotations to _pytest._code.code 2019-11-16 22:29:57 +02:00
Daniel Hahler
e3796047c1 pre-commit: upgrade black (#6208) 2019-11-16 19:20:12 +01:00
Daniel Hahler
54a954514b re-run black 2019-11-16 18:55:32 +01:00
Daniel Hahler
b1a597ab02 Remove (now) unnecessary fmt: off 2019-11-16 18:51:02 +01:00
Daniel Hahler
5d247b9caf pre-commit: upgrade black
This brings https://github.com/psf/black/pull/826, which helps with
https://github.com/psf/black/issues/601.
2019-11-16 18:42:17 +01:00
Daniel Hahler
4b7148f9a4 cacheprovider: set: use json.dumps + write (#6206) 2019-11-16 18:25:28 +01:00
Daniel Hahler
786d839db1 cacheprovider: set: use json.dumps + write
``json.dump`` is slower since it iterates over chunks [1].

For 100 ``cache.set`` calls this saved ~0.5s (2.5s => 2s), using a dict
with 1500 entries, and an encoded size of 500kb.

Python 3.7.4.

1: https://github.com/blueyed/cpython/blob/1c2e81ed00/Lib/json/__init__.py#L177-L180
2019-11-16 17:40:56 +01:00
Ran Benita
562d4811d5 Add type annotations to _pytest.compat 2019-11-16 17:22:11 +02:00
Ran Benita
a649f157de Make Source explicitly implement __iter__()
Source was previously iterable because it implements `__getitem__()`,
which is apparently a thing from before `__iter__()` was introduced.
To reduce mypy's and my own confusion, implement `__iter__()` directly.
2019-11-16 17:22:10 +02:00
Ran Benita
307add025b Simplify a FormattedExcinfo test
The previous test was better in that it used fakes to test all of the
real code paths. The problem with that is that it makes it impossible to
simplify the code with `isinstance` checks. So let's just simulate the
issue directly with a monkeypatch.
2019-11-16 17:22:09 +02:00
Ran Benita
e3ac44df36 Inline the FuncargnamesCompatAttr compat helper
It doesn't help much IMO, just adds indirection and makes it harder to
type.
2019-11-16 17:22:09 +02:00
Ran Benita
5bfe793fd5 Remove unneeded getrawcode() calls from tests 2019-11-16 17:22:08 +02:00
Ran Benita
04d68fbc9e Remove checks for Python2-only fields im_func and func_code 2019-11-16 17:22:07 +02:00
Ran Benita
c7a83a0f31 Remove a PyPy version check for an unsupported version
pytest doesn't support these PyPy versions anymore, so no need to have
checks for them.
2019-11-16 17:22:07 +02:00
Ran Benita
f760356578 A few linting fixes
Add some Python 3.8 type: ignores; all are already fixed in the next
mypy release, so can be removed once we upgrade.

Also move some flake8 ignores which seem to have changed places.
2019-11-16 17:22:06 +02:00
Zac Hatfield-Dodds
f24f20a46e Merge pull request #6204 from TH3CHARLie/add-changelog-on-tmp_path_factory
changelog: #3985 also introduce `tmp_path_factory`
2019-11-16 23:57:53 +11:00
TH3CHARLie
b090ac6204 remove trailing-whitespace 2019-11-16 18:01:08 +08:00
TH3CHARLie
9c681b45e3 change: #3985 also introduce 2019-11-16 17:34:05 +08:00
林玮
329f56ecec Fix incorrect result of getmodpath method. 2019-11-16 15:28:04 +08:00
Anthony Sottile
cc78444c30 Merge remote-tracking branch 'origin/master' into mm 2019-11-15 15:26:57 -08:00
Anthony Sottile
3a668ea6ff Merge pull request #6198 from asottile/release-5.2.4
Preparing release version 5.2.4
2019-11-15 14:57:08 -08:00
Daniel Hahler
c49c61fdaf Import Path from _pytest.pathlib for py35 (#6193) 2019-11-15 23:17:43 +01:00
Daniel Hahler
1abb08d52f tests: use sys.dont_write_bytecode
Setting PYTHONDONTWRITEBYTECODE in the environment does not change it
for the current process.
2019-11-15 23:13:08 +01:00
Anthony Sottile
c9a96cdee8 Preparing release version 5.2.4 2019-11-15 13:26:56 -08: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
Anthony Sottile
19a15a94ee Merge pull request #6197 from asottile/fix_init_py_discovery
Fix incorrect discovery of non-test `__init__.py` files.
2019-11-15 13:19:48 -08:00
Anthony Sottile
4e0f99260d Add regression tests for __init__.py breakage 2019-11-15 13:19:31 -08:00
Anthony Sottile
176c7771fb Revert "fix bug with nonskipped first test in package (#5831)"
This reverts commit 85288b5321, reversing
changes made to 5f9db8a017.
2019-11-15 08:29:52 -08:00
Bruno Oliveira
d2ea9e2db5 Remove report_log in favor of pytest-reportlog
Fix #6180
2019-11-14 19:47:26 -03:00
Bruno Oliveira
e856638ba0 Preparing release version 5.2.3 (#6190)
Preparing release version 5.2.3
2019-11-14 18:17:28 -03:00
Bruno Oliveira
99f487864c Issue a warning to prepare change of 'junit_family' default val… (#6186)
Issue a warning to prepare change of 'junit_family' default value
2019-11-14 18:11:10 -03:00
Daniel Hahler
d4e4ab5b3d Update text in PR template (#6188) 2019-11-14 21:30:16 +01:00
Bruno Oliveira
e2a0987156 Update advice about _called_from_test. (#6168)
Update advice about _called_from_test.
2019-11-14 17:10:53 -03:00
Michael Shields
bd68c2a3dc Update advice about _called_from_test.
Instead of giving an example of using sys and then, at the end,
advising not to use sys, just give a correct example. This is
especially helpful since mypy 0.740 has started (correctly) complaining
about sys._called_from_pytest not being present.
2019-11-14 19:44:27 +00:00
Hugo
48ec7d28c6 Make whole checklist a comment to avoid incomplete TODOs in PRs 2019-11-14 12:01:40 +02:00
Hugo
350c27c8b4 Update text in PR template 2019-11-14 11:36:47 +02:00
Daniel Hahler
2fc7d04fc3 Merge pull request #6187 from blueyed/minor
Minor fixes
2019-11-14 00:45:54 +01:00
Bruno Oliveira
2a67637acc Issue a warning to prepare change of 'junit_family' default value
Fix #6179
2019-11-13 19:55:13 -03:00
Daniel Hahler
772dfc4f9d terminal: fix/remove wrong typing for currentfspath
Can be -2, or py.path.local (not typed).
2019-11-13 23:24:24 +01:00
Daniel Hahler
55bc084dcc doc: s/_pytest.config.Parser/_pytest.config.argparsing.Parser/ 2019-11-13 23:22:25 +01:00
Daniel Hahler
b3bb604683 fix typo in _issue_warning_captured doc 2019-11-13 23:22:25 +01:00
Daniel Hahler
f91bf48a40 Merge pull request #6176 from blueyed/assertoutcome
pytester: Hookrecorder: improve assertoutcome
2019-11-13 19:27:18 +01:00
Daniel Hahler
a6e10cc2e3 Merge pull request #6181 from blueyed/maxfail-terminal-upstream
terminal: report ``session.shouldfail`` reason (``-x``)
2019-11-13 19:27:01 +01:00
Daniel Hahler
c232366f2f Merge pull request #6171 from blueyed/rm-xfail
tests: remove test_nested_marks (xfail)
2019-11-13 16:23:55 +01:00
Daniel Hahler
b06f33f474 terminal: report `session.shouldfail reason (-x`)
Via https://github.com/blueyed/pytest/pull/108.
2019-11-13 16:18:41 +01:00
Daniel Hahler
6ddf7c3d42 pytester: Hookrecorder: improve assertoutcome
Before:

        def assertoutcome(self, passed: int = 0, skipped: int = 0, failed: int = 0) -> None:
            realpassed, realskipped, realfailed = self.listoutcomes()
            assert passed == len(realpassed)
    >       assert skipped == len(realskipped)
    E       assert 1 == 0
    E        +  where 0 = len([])

After:

    >       reprec = testdir.inline_run(testpath, "-s")
    E       AssertionError: ([], [], [<TestReport 'nodeid' when='call' outcome='failed'>])
    E       assert {'failed': 1, 'passed': 0, 'skipped': 0} == {'failed': 0, 'passed': 0, 'skipped': 1}
2019-11-13 13:48:20 +01:00
Daniel Hahler
e2022a6d48 pytester: assert_outcomes: use/set __tracebackhide__ (#6172) 2019-11-12 23:07:58 +01:00
Bruno Oliveira
59369651db Bring back explicit tear down
Otherwise 'normal' failures won't call teardown explicitly
2019-11-12 14:03:40 -03:00
Bruno Oliveira
1b84f099b6 Merge pull request #6170 from blueyed/imp
filterwarnings: ignore DeprecationWarning from nose
2019-11-12 13:00:50 -03:00
Bruno Oliveira
f7b1de70c0 No need to call tearDown on expected failures
- Isolate logic for getting expected exceptions
- Use original method name, as users see it when entering the debugger
2019-11-12 12:50:55 -03:00
Daniel Hahler
86e9ae39f0 pytester: assert_outcomes: use/set __tracebackhide__ 2019-11-12 15:28:36 +01:00
Daniel Hahler
dad4985be1 A bit more typing around Node (#6167) 2019-11-12 14:46:05 +01:00
Daniel Hahler
fc1c015c6b tests: remove test_nested_marks (xfail)
It currently fails with a TypeError, and was not updated since 2013 -
therefore it can be assumed that it is not important to support it.

```
____________________ ERROR collecting test_nested_marks.py _____________________
…/Vcs/pluggy/src/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:337: in traced_hookexec
    return outcome.get_result()
…/Vcs/pluggy/src/pluggy/manager.py:335: in <lambda>
    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
…/Vcs/pluggy/src/pluggy/manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
…/Vcs/pytest/src/_pytest/python.py:235: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
…/Vcs/pytest/src/_pytest/python.py:404: in _genfunctions
    self.ihook.pytest_generate_tests.call_extra(methods, dict(metafunc=metafunc))
…/Vcs/pluggy/src/pluggy/hooks.py:324: in call_extra
    return self(**kwargs)
…/Vcs/pluggy/src/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:337: in traced_hookexec
    return outcome.get_result()
…/Vcs/pluggy/src/pluggy/manager.py:335: in <lambda>
    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
…/Vcs/pluggy/src/pluggy/manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
…/Vcs/pytest/src/_pytest/python.py:130: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs)
…/Vcs/pytest/src/_pytest/python.py:965: in parametrize
    function_definition=self.definition,
…/Vcs/pytest/src/_pytest/mark/structures.py:111: in _for_parametrize
    if len(param.values) != len(argnames):
E   TypeError: object of type 'MarkDecorator' has no len()
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
```
2019-11-12 14:44:03 +01:00
Daniel Hahler
4c7d971f13 filterwarnings: ignore DeprecationWarning from nose
This comes via hypothesis:

```
% COLUMNS=80 p testing/python/metafunc.py::TestMetafunc::test_idval_hypothesis -vv --tb=short
============================= test session starts ==============================
platform linux -- Python 3.7.4, pytest-3.1.4.dev721+g3367bf03b.d20191112, py-1.8.1.dev11+g34f716fe, pluggy-0.13.1.dev8+ga5130ac.d20191103 -- …/Vcs/pytest/.venv/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('…/Vcs/pytest/.hypothesis/examples')
rootdir: …/Vcs/pytest, inifile: tox.ini
plugins: forked-1.1.3, hypothesis-4.44.1, cov-2.8.1, coverage-pytest-plugin-0.1, enhancements-0.0.5.dev1-gf361636-dirty, xdist-1.30.0
collected 1 item

testing/python/metafunc.py::TestMetafunc::test_idval_hypothesis FAILED   [100%]

=================================== FAILURES ===================================
______________________ TestMetafunc.test_idval_hypothesis ______________________
.venv/lib/python3.7/site-packages/hypothesis/core.py:588: in evaluate_test_data
    result = self.execute(data)
.venv/lib/python3.7/site-packages/hypothesis/core.py:553: in execute
    result = self.test_runner(data, run)
.venv/lib/python3.7/site-packages/hypothesis/executors.py:56: in default_new_style_executor
    return function(data)
.venv/lib/python3.7/site-packages/hypothesis/core.py:536: in run
    args, kwargs = data.draw(self.search_strategy)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:857: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/core.py:223: in do_draw
    return self.mapped_strategy.do_draw(data)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/collections.py:60: in do_draw
    return tuple(data.draw(e) for e in self.element_strategies)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/collections.py:60: in <genexpr>
    return tuple(data.draw(e) for e in self.element_strategies)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/strategies.py:570: in do_draw
    result = self.pack(data.draw(self.mapped_strategy))
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/lazy.py:156: in do_draw
    return data.draw(self.wrapped_strategy)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/strategies.py:570: in do_draw
    result = self.pack(data.draw(self.mapped_strategy))
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/collections.py:60: in do_draw
    return tuple(data.draw(e) for e in self.element_strategies)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/collections.py:60: in <genexpr>
    return tuple(data.draw(e) for e in self.element_strategies)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/strategies.py:508: in do_draw
    return data.draw(self.element_strategies[i], label=self.branch_labels[i])
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/lazy.py:156: in do_draw
    return data.draw(self.wrapped_strategy)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/strategies.py:570: in do_draw
    result = self.pack(data.draw(self.mapped_strategy))
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/lazy.py:156: in do_draw
    return data.draw(self.wrapped_strategy)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/collections.py:120: in do_draw
    result.append(data.draw(self.element_strategy))
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/numbers.py:62: in do_draw
    return d.integer_range(data, self.start, self.end)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/utils.py:105: in integer_range
    probe = data.draw_bits(bits)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:974: in draw_bits
    self.__check_capacity(n_bytes)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:1019: in __check_capacity
    self.mark_overrun()
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:1036: in mark_overrun
    self.conclude_test(Status.OVERRUN)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:1027: in conclude_test
    raise StopTest(self.testcounter)
E   hypothesis.errors.StopTest: 0

During handling of the above exception, another exception occurred:
testing/python/metafunc.py:195: in test_idval_hypothesis
    @hypothesis.settings(
.venv/lib/python3.7/site-packages/nose/__init__.py:1: in <module>
    from nose.core import collector, main, run, run_exit, runmodule
.venv/lib/python3.7/site-packages/nose/core.py:12: in <module>
    from nose.loader import defaultTestLoader
.venv/lib/python3.7/site-packages/nose/loader.py:21: in <module>
    from nose.importer import Importer, add_path, remove_path
.venv/lib/python3.7/site-packages/nose/importer.py:12: in <module>
    from imp import find_module, load_module, acquire_model1, release_model1
/usr/lib/python3.7/imp.py:33: in <module>
    DeprecationWarning, stacklevel=2)
E   DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
---------------------------------- Hypothesis ----------------------------------
You can add @seed(198901559535749756451579900660745168041) to this test or run pytest with --hypothesis-seed=198901559535749756451579900660745168041 to reproduce this failure.
=============================== warnings summary ===============================
testing/python/metafunc.py::TestMetafunc::test_idval_hypothesis
  …/Vcs/pytest/.venv/lib/python3.7/site-packages/unittest2/compatibility.py:143: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    class ChainMap(collections.MutableMapping):

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================== short test summary info ============================
FAILED testing/python/metafunc.py::TestMetafunc::test_idval_hypothesis - Depr...
```
2019-11-12 14:32:11 +01:00
Ran Benita
b352e34938 Merge pull request #6149 from bluetech/cached-property
Add a @cached_property implementation
2019-11-10 22:11:04 +02:00
Daniel Hahler
3ef8aa8173 A bit more typing around Node 2019-11-10 19:06:27 +01:00
Daniel Hahler
abcedd6095 _compare_eq_iterable: use AlwaysDispatchingPrettyPrinter (#6151) 2019-11-10 14:08:25 +01:00
Ran Benita
42a46ea786 Add a @cached_property implementation
This is a useful utility to abstract the caching property idiom.

It is in compat.py since eventually it will be replaced by
functools.cached_property.

Fixes #6131.
2019-11-10 10:21:55 +02:00
Daniel Hahler
04f27d4eb4 unittest: do not use TestCase.debug() with --pdb
Fixes https://github.com/pytest-dev/pytest/issues/5991
Fixes https://github.com/pytest-dev/pytest/issues/3823

Ref: https://github.com/pytest-dev/pytest-django/issues/772
Ref: https://github.com/pytest-dev/pytest/pull/1890
Ref: https://github.com/pytest-dev/pytest-django/pull/782

- inject wrapped testMethod

- adjust test_trial_error

- add test for `--trace` with unittests
2019-11-10 00:21:51 +01:00
Daniel Hahler
710e3c40e0 typing around terminal (#6157) 2019-11-10 00:19:11 +01:00
Daniel Hahler
0bbc032db0 [WIP] typing around terminal 2019-11-09 23:53:37 +01:00
Daniel Hahler
96c315e439 showversion: no need for py.path.local (#6163) 2019-11-09 22:45:02 +01:00
Daniel Hahler
28edbaace4 showversion: no need for py.path.local 2019-11-09 21:45:35 +01:00
Bruno Oliveira
245e1f10e5 Merge pull request #6152 from grlee77/module_name_in_id
use __name__ attribute in the parametrize id for modules as well
2019-11-08 14:16:34 -03:00
Bruno Oliveira
c16b121594 Add CHANGELOG for #6152 2019-11-08 10:52:04 -03:00
Bruno Oliveira
04891048e1 Two minor tweaks in MarkDecorator's implementation (#6150)
Two minor tweaks in MarkDecorator's implementation
2019-11-08 10:46:48 -03:00
Ran Benita
84b2c81db4 Drop the "alias" helper used in MarkDecorator
It is a little too obscure IMO, but the reason I want to drop it is that
type checking has no hope of understanding such dynamic constructs.

The warning argument wasn't used.
2019-11-08 11:22:46 +02:00
Ran Benita
984d90a811 Drop redundant custom MarkDecorator __eq__ implementation
This is already covered by attrs.

Also, the custom implementation returns False when the types don't
match, but it's better to return `NotImplemented`. attrs does this.
2019-11-08 11:14:31 +02:00
Gregory Lee
db82432ec8 add minimal test case 2019-11-08 01:39:29 -05:00
Gregory Lee
cc6c5e15b8 update AUTHORS list 2019-11-08 01:39:29 -05:00
Gregory Lee
c22ce1a12c parametrize: allow __name__ id for modules or other objects as well 2019-11-08 01:39:29 -05:00
Daniel Hahler
cc503c1821 _compare_eq_iterable: use AlwaysDispatchingPrettyPrinter
This fixes/removes the previous hack of re-trying with minimum width,
which fails short when it splits strings.

This inherits from `pprint.PrettyPrinter` to override `_format` in a
minimal way to always dispatch, regardless of the given width.

Code ref: 5c0c325453/Lib/pprint.py (L170-L178)
2019-11-08 04:07:09 +01:00
Bruno Oliveira
6ad95716da add --co option to collect-only (#6116)
add --co option to collect-only
2019-11-07 19:03:32 -03:00
Bruno Oliveira
3b243404e6 Explicitly implement pytest_assertrepr_compare in assertion plu… (#6140)
Explicitly implement pytest_assertrepr_compare in assertion plugin
2019-11-07 18:45:26 -03:00
Daniel Hahler
09709bba06 Use atomicrewrites only on Windows (#6148) 2019-11-07 22:13:26 +01:00
Daniel Hahler
40626f48e7 Update changelog/6148.improvement.rst
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2019-11-07 22:13:03 +01:00
Bruno Oliveira
7ed33996f1 on_rm_rf_error: ignore os.open (no warning) (#6074)
on_rm_rf_error: ignore os.open (no warning)
2019-11-07 18:06:05 -03:00
Bruno Oliveira
0cf2002a1f Explicitly implement pytest_assertrepr_compare in assertion plugin
Previously it was an alias, which makes it unnecessary hard to find
all implementations (either by IDE or using a simple search).
2019-11-07 18:00:27 -03:00
NNRepos
4946cc8282 Add --co option to collect-only
Fix #5845
2019-11-07 17:50:27 -03:00
Daniel Hahler
45c4a8fb3d Use atomicrewrites only on Windows
Fixes https://github.com/pytest-dev/pytest/issues/6147
2019-11-07 20:57:45 +01:00
Ran Benita
e670ff76cb Merge pull request #6141 from bluetech/type-annotations-7
Add type annotations to _pytest.{warning_types,_code.source,pytester}
2019-11-07 17:11:01 +02:00
Daniel Hahler
19b2f4bb8a tests: use ids (#6145) 2019-11-07 14:43:46 +01:00
Daniel Hahler
f11237b066 _perform_collect: remove comment about untested code (#6144) 2019-11-07 13:18:08 +01:00
Daniel Hahler
14eaa05b60 Merge pull request #6143 from blueyed/test_source
test_source: do not instantiate Source objects during collection
2019-11-07 13:16:34 +01:00
Ran Benita
265a9eb6a2 Add type annotations to some of _pytest.pytester 2019-11-07 14:13:47 +02:00
Ran Benita
58f2849bf6 Add type annotations to _pytest._code.source
At least most of it.
2019-11-07 14:13:47 +02:00
Ran Benita
b2537b22d7 Add type annotations to _pytest.warning_types 2019-11-07 14:11:39 +02:00
Daniel Hahler
2adc84ed6c changelog 2019-11-07 12:55:01 +01:00
Daniel Hahler
2e5cf1cc78 Fix order of format args with warning 2019-11-07 12:50:04 +01:00
Daniel Hahler
8aa0809fbc on_rm_rf_error: ignore os.open (no warning)
Ref: https://github.com/pytest-dev/pytest/pull/6044/files#r339321752
2019-11-07 12:50:04 +01:00
Daniel Hahler
ab101658f0 saferepr: handle BaseExceptions (#6047) 2019-11-07 12:33:22 +01:00
Daniel Hahler
b268463243 Merge master into features (#6111) 2019-11-07 12:31:33 +01:00
Daniel Hahler
dd852ded70 _perform_collect: remove comment about untested code
Harden one test where it is tested.

All tests testing this:

    testing/acceptance_test.py:184(TestGeneralUsage::test_not_collectable_arguments)
    testing/acceptance_test.py:373(TestGeneralUsage::test_direct_addressing_notfound)
    testing/acceptance_test.py:403(TestGeneralUsage::test_issue134_report_error_when_collecting_member[test_fun.py::test_a])
    testing/acceptance_test.py:420(TestGeneralUsage::test_report_all_failed_collections_initargs)
    testing/test_config.py:1309(test_config_blocked_default_plugins[python])

(via https://github.com/blueyed/pytest/pull/88)
2019-11-07 12:29:36 +01:00
Daniel Hahler
dd6cf7c172 test_exc_chain_repr_without_traceback: use ids 2019-11-07 12:25:46 +01:00
Daniel Hahler
5c00226847 test_iterable_full_diff: use test ids 2019-11-07 12:24:01 +01:00
Daniel Hahler
e8a3d1adf2 Fix test_trace_with_parametrize_handles_shared_fixtureinfo for colors 2019-11-07 11:48:51 +01:00
Daniel Hahler
cb21a8db1d test_source: do not instantiate Source objects during collection 2019-11-07 11:44:26 +01:00
Daniel Hahler
0c0d33f78e Session: collect: keep/use already parsed initialpart (#6120) 2019-11-07 11:16:24 +01:00
Daniel Hahler
c4a110b20a Session: collect: keep/use already parsed initialpart
Via https://github.com/blueyed/pytest/pull/42.
2019-11-06 22:09:24 +01:00
Daniel Hahler
fee7c7b032 py38: do not call None() directly
Works around:

    _____ ERROR collecting testing/io/test_saferepr.py _____
    src/_pytest/python.py:502: in _importtestmodule
        mod = self.fspath.pyimport(ensuresyspath=importmode)
    .venv38/lib/python3.8/site-packages/py/_path/local.py:701: in pyimport
        __import__(modname)
    <frozen importlib._bootstrap>:991: in _find_and_load
        ???
    <frozen importlib._bootstrap>:975: in _find_and_load_unlocked
        ???
    <frozen importlib._bootstrap>:671: in _load_unlocked
        ???
    src/_pytest/assertion/rewrite.py:136: in exec_module
        source_stat, co = _rewrite_test(fn, self.config)
    src/_pytest/assertion/rewrite.py:288: in _rewrite_test
        co = compile(tree, fn, "exec", dont_inherit=True)
    E     File "…/Vcs/pytest/testing/io/test_saferepr.py", line 45
    E       None()
    E       ^
    E   SyntaxError: 'NoneType' object is not callable; perhaps you missed a comma?
2019-11-06 22:08:10 +01:00
Daniel Hahler
eb7a4e32ad saferepr: handle BaseExceptions
This causes INTERNALERRORs with pytest-django, which uses
`pytest.fail` (derived from `BaseException`) to prevent DB access, when
pytest then tries to e.g. display the `repr()` for a Django `QuerySet`
etc.

Ref: https://github.com/pytest-dev/pytest-django/pull/776
2019-11-06 22:08:10 +01:00
Daniel Hahler
5be3a9b5ce tests: speed up test_faulthandler.test_timeout (#6075) 2019-11-06 22:07:28 +01:00
Daniel Hahler
fe429d4ce8 assert: fix _compare_eq_iterable: re-format both sides (#6137) 2019-11-06 22:06:39 +01:00
Steffen Schroeder
ceeb7bd085 Fixed broken links 2019-11-06 20:54:41 +01:00
Steffen Schroeder
1cecdf6619 Added checklinks to tox and release.py 2019-11-06 20:54:41 +01:00
Bruno Oliveira
5738d189a4 [RDY] tox: remove platform restriction, only used for pexpect (#6068)
[RDY] tox: remove platform restriction, only used for pexpect
2019-11-06 16:09:27 -03:00
Bruno Oliveira
74f4ec5986 Making it possible to access the pluginmanager in the pytest_ad… (#6106)
Making it possible to access the pluginmanager in the pytest_addoptio…
2019-11-06 15:18:59 -03:00
Daniel Hahler
8dcee39ce9 Merge pull request #6103 from blueyed/lsof_check
tests: lsof_check: include exc with skip message
2019-11-06 18:44:19 +01:00
Daniel Hahler
4e45472405 Merge master into features
Conflicts:
	src/_pytest/debugging.py
2019-11-06 14:22:07 +01:00
Daniel Hahler
92b436c938 Merge pull request #6136 from blueyed/fix-rm_rf-tests
Fix rm_rf tests
2019-11-06 14:19:47 +01:00
Daniel Hahler
01769b141a Merge pull request #6100 from blueyed/fix-skip-offset
terminal: fix line offset with skip reports
2019-11-06 13:29:40 +01:00
Daniel Hahler
0485b07ff0 Merge pull request #6071 from blueyed/tests-doctest-mock
Tests: approx: mock doctest runner's pdb usage
2019-11-06 13:27:50 +01:00
Daniel Hahler
eb4b3ce1c8 Merge pull request #6084 from blueyed/merge-rm
tests: merge/remove test_dontreadfrominput_buffer_python3
2019-11-06 13:24:47 +01:00
Daniel Hahler
9071a2a5e0 Merge pull request #6119 from blueyed/FSCollector-fspath
FSCollector: keep/use given fspath
2019-11-06 13:10:27 +01:00
Daniel Hahler
ce3d431002 assert: fix _compare_eq_iterable: re-format both sides
Follow-up to 946434c61 (#5924).

Before this patch the test would look like this:

    {'env': {'sub...s wrapped'}}}} == {'env': {'sub...}}}, 'new': 1}
    Omitting 1 identical items, use -vv to show
    Right contains 1 more item:
    {'new': 1}
    Full diff:
      {
       'env': {'sub': {'long_a': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
    -                  'sub1': {'long_a': 'substring '
    +                  'sub1': {'long_a': 'substring that gets wrapped'}}},
    ?                                                +++++++++++++++++ ++++
    +  'new': 1,
    -                                     'that '
    -                                     'gets '
    -                                     'wrapped'}}},
      }
2019-11-06 11:23:15 +01:00
Daniel Hahler
e7320c6b54 Merge pull request #5926 from AtakamaLLC/optional-multiline
Add log-auto-indent option to control multiline formatting
2019-11-06 00:35:24 +01:00
Daniel Hahler
00f67494e5 Merge pull request #6107 from MarcoGorelli/color-percentage-indicator
Color percentage indicator
2019-11-06 00:28:45 +01:00
Daniel Hahler
d8096925fa Fix for Python 3.5 not handling LocalPath 2019-11-06 00:22:46 +01:00
Daniel Hahler
9309ae299a Use try/finally to ensure chmod is run, filter warning 2019-11-05 22:28:32 +01:00
Daniel Hahler
dc2c51302a Revert "tests: filterwarnings: do not crash with "(rm_rf)" warning"
This reverts commit 6b2bae9392.
2019-11-05 22:11:56 +01:00
Tibor Arpas
262ed567d0 tests: clean up chmod-related tests to fix rm_rf warnings
Fixed https://github.com/pytest-dev/pytest/issues/5974#issuecomment-549822509.
2019-11-05 22:10:27 +01:00
Daniel Hahler
0794289689 Merge pull request #6129 from blueyed/typing
Typing around Node.location, reportinfo, repr_excinfo etc
2019-11-05 18:29:29 +01:00
Daniel Hahler
cab29dc861 Merge pull request #6124 from blueyed/test_group_warnings_by_message-ignore-own-warning
test_group_warnings_by_message: ignore own PytestExperimentalApiWarning
2019-11-05 16:24:10 +01:00
Daniel Hahler
741f0fedd1 typing around Node.location, reportinfo, repr_excinfo etc 2019-11-05 16:22:58 +01:00
MarcoGorelli
0d79061432 Color percentage indicator according to color of final line
indicate current outcome/status with color of percentage indicator

Fix type annotation, refactor _write_progress_information_filling_space

Keep code in _get_main_color as similar as possible to how it was before

Write test

Make black-compliant

Fix error in newly introduced test_collecterror

Make tests more readable by using constants and f-strings

Remove accidentally added monkeypatch

Make Python 3.5-compatible, add changelog entry

Add newline at the end of changelog file
2019-11-04 19:57:07 +00:00
Daniel Hahler
d53794f916 Merge pull request #6125 from blueyed/upstream-test_terminal-fulltrace
test_terminal: reduce number of tests (single --fulltrace param)
2019-11-04 11:50:18 +01:00
Ran Benita
08c25b7fe0 Merge pull request #6122 from bluetech/type-annotations-6
Add type annotations to _pytest._io.saferepr and _pytest.assertion.util._diff_text
2019-11-04 09:58:09 +02:00
Daniel Hahler
9f800b2a77 test_terminal: reduce number of tests (single --fulltrace param)
Remove the `--fulltrace` arg from the `Option` fixture used in several
tests, but not checked for.  Only use it with `test_keyboard_interrupt`.

(removes 8 tests, coverage not affected)
2019-11-03 21:23:18 +01:00
Daniel Hahler
68dbc24dcb test_group_warnings_by_message: ignore own PytestExperimentalApiWarning 2019-11-03 21:14:24 +01:00
Ran Benita
7d3ce374d2 Add type annotations to _pytest.assertion.util 2019-11-03 20:28:43 +02:00
Ran Benita
18d181fa77 Remove dead code in _pytest.assertion.util._diff_text
The function handles bytes input, however that is never used.
The function has two callers:

1)

```
            if istext(left) and istext(right):
                explanation = _diff_text(left, right, verbose
```

`istext` checks `isinstance(str)`.

2)

```
def _notin_text(term: str, text: str, verbose: int = 0) -> List[str]:
    ...
    diff = _diff_text(correct_text, text, verbose
```

and `_notin_text` is called once:

```
            if istext(left) and istext(right):
                explanation = _notin_text(left, right, verbose
```
2019-11-03 20:28:43 +02:00
Ran Benita
dc30d78845 Add type annotations to _pytest._io.saferepr 2019-11-03 20:28:43 +02:00
MarcoGorelli
9303de877a Fix error in newly introduced test_collecterror
Via https://github.com/pytest-dev/pytest/pull/6107.

(cherry picked from commit 1b9fbbfa195aa20c48574265935dc5e66b96ec16)
2019-11-03 18:16:46 +01:00
Daniel Hahler
3fb969897a Merge pull request #6059 from blueyed/collect-error-short-summary
terminal: report collection errors as "ERROR" in short summary
2019-11-02 15:34:12 +01:00
Daniel Hahler
6df4d07a57 Merge pull request #6067 from blueyed/harden-test
tests: harden test_disabled_capture_fixture
2019-11-02 15:33:55 +01:00
Bruno Oliveira
0947ecd6f0 Change 5924 and 5936 changelog entries to improvement (#6065)
Change 5924 and 5936 changelog entries to improvement
2019-11-02 11:23:06 -03:00
Daniel Hahler
0c7c26fe6e FSCollector: keep/use given fspath
Via https://github.com/blueyed/pytest/pull/42.
2019-11-02 10:02:23 +01:00
Daniel Hahler
7f851a215b Merge pull request #6032 from blueyed/ci-branches
ci: Travis: configure/restrict branch builds
2019-10-31 10:38:01 +01:00
Joshua Storck
f400804206 Removing pluginmanager as parameter in definition of pytest_addoption hook 2019-10-30 16:25:50 -04:00
Joshua Storck
0027908e9e Removing :py:func: and :ref: from changelog as it's not supported by towncrier 2019-10-30 15:02:18 -04:00
Joshua Storck
7a96d94fd4 Making it possible to access the pluginmanager in the pytest_addoption hook 2019-10-30 14:18:13 -04:00
Bruno Oliveira
3406857284 Introduce --report-log (#5980)
Introduce --report-log
2019-10-30 10:24:35 -03:00
Bruno Oliveira
09096f7436 Remove 'experimental' status from report serialization hooks 2019-10-30 09:43:33 -03:00
Bruno Oliveira
b99661b9d7 Introduce --report-log option
Fix #4488
2019-10-30 09:43:33 -03:00
Daniel Hahler
8c21416798 lsof_check: include exc with skip message 2019-10-29 15:25:15 +01:00
Daniel Hahler
6d2cabae57 terminal: fix line offset with skip reports
The original fix in https://github.com/pytest-dev/pytest/pull/2548 was
wrong, and was likely meant to fix the use with decorators instead,
which this does now (while reverting 869eed9898).
2019-10-29 13:11:02 +01:00
Daniel Hahler
0225cb37c0 Merge pull request #6077 from blueyed/ci-remove-single-py37-pexpect
ci: Travis: include pexpect in main py37 job
2019-10-28 17:05:31 +01:00
Daniel Hahler
cdc53da19c Merge pull request #5990 from MarcoGorelli/plurality-matching
Plurality matching
2019-10-28 17:03:15 +01:00
Daniel Hahler
e7898dedf4 Merge pull request #6093 from blueyed/fix-flaky
tests: fix testing/test_capture.py::test_typeerror_encodedfile_write
2019-10-28 16:17:46 +01:00
Daniel Hahler
6d33f4cdce Merge pull request #6076 from blueyed/runpytest_subprocess-slowest
tests: conftest: handle tests using runpytest_subprocess as "slowest"
2019-10-28 14:49:54 +01:00
Daniel Hahler
60ceec6eb1 tests: fix testing/test_capture.py::test_typeerror_encodedfile_write
Failed for me due to different indent (?) - not reproducible:

    >   ???
    E   Failed: nomatch: 'E           TypeError: write() argument must be str, not bytes'
    …
    E       and: '>   def mode(self):'
    E       and: 'E   TypeError: write() argument must be str, not bytes'
    …
    E   remains unmatched: 'E           TypeError: write() argument must be str, not bytes'
2019-10-28 14:37:26 +01:00
Ran Benita
7f8bf4d9f6 Merge pull request #6066 from bluetech/type-annotations-paths
Add type annotations to _pytest.pathlib and _pytest.tmpdir
2019-10-28 15:20:45 +02:00
Daniel Hahler
a4554e666a tests: speed up test_faulthandler.test_timeout 2019-10-28 13:44:06 +01:00
Daniel Hahler
d6e324a5e6 tests: conftest: handle tests using runpytest_subprocess as "slowest" 2019-10-28 13:43:42 +01:00
Daniel Hahler
023dde89e1 ci: Travis: include pexpect in main py37 job
This removes xdist there (not compatible with the pexpect tests), but it
is better to have one job less, although slower due to not using xdist.
2019-10-28 13:39:43 +01:00
Daniel Hahler
a5bd19e3b4 tests: lazily import doctest in approx tests 2019-10-28 12:55:16 +01:00
Daniel Hahler
32412532ef tests: mock doctest.DocTestRunner to not use real pdb
It is not used there anyway, and might cause false positives.
2019-10-28 12:55:16 +01:00
Daniel Hahler
ec27363748 Merge pull request #6025 from blueyed/pytester-typing
pytester: typing
2019-10-28 05:31:31 +01:00
Daniel Hahler
716f532a38 Merge pull request #6070 from blueyed/pexpect-freebsd
pytester: spawn: do not skip FreeBSD
2019-10-28 05:13:31 +01:00
Daniel Hahler
820b747e7a tests: merge/remove test_dontreadfrominput_buffer_python3 2019-10-27 19:32:06 +01:00
MarcoGorelli
d863c30c74 Fix plurality mismatch for and in pytest terminal summary 2019-10-27 15:16:24 +00:00
Daniel Hahler
886a3ad609 pytester: typing 2019-10-27 12:32:14 +01:00
Daniel Hahler
cbc39dd86e Merge pull request #6079 from blueyed/tryfirst
mark: move pytest_cmdline_main.tryfist into decorator
2019-10-27 07:21:31 +01:00
Daniel Hahler
a4faac6c94 mark: move pytest_cmdline_main.tryfist into decorator
Avoids comments for ignored typing.
2019-10-27 06:01:18 +01:00
Daniel Hahler
81c3bc76bc tests: harden test_disabled_capture_fixture 2019-10-27 03:02:24 +01:00
Daniel Hahler
a92f49afa7 Merge pull request #6073 from blueyed/merge-master-into-features
Merge master into features
2019-10-27 02:57:00 +01:00
Daniel Hahler
7f1af84f47 Merge master into features
Conflicts:
	src/_pytest/logging.py
2019-10-27 02:06:36 +01:00
Daniel Hahler
8e8a8fa4b9 pytester: spawn: do not skip FreeBSD
Fixes https://github.com/pytest-dev/pytest/issues/6069
2019-10-27 00:44:25 +02:00
Daniel Hahler
be514178d0 tox: remove platform restriction, only used for pexpect
This would prevent TOXENV=py37-pexpect-… from running on e.g. FreeBSD.
And even on Windows it is pytest's job of skipping the tests then.  This
was probably still from when the pexpect env was only running
pexpect-based tests.
2019-10-27 00:23:25 +02:00
Ran Benita
00a278cdb4 Add type annotations to _pytest.tmpdir
At least the ones I was able to.
2019-10-26 20:30:44 +03:00
Ran Benita
59a59f371b Add type annotations to _pytest.pathlib
At least the ones I was sure of.
2019-10-26 20:08:36 +03:00
Bruno Oliveira
928587da60 Change 5924 and 5936 changelog entries to improvement [ci skip] 2019-10-26 13:02:47 -03:00
Bruno Oliveira
1ad4ca6ac1 Support sys.pycache_prefix on py38 (#5864)
Support sys.pycache_prefix on py38
2019-10-26 11:29:09 -03:00
Bruno Oliveira
6f20b4b014 Introduce compat.fspath 2019-10-26 10:37:44 -03:00
Bruno Oliveira
f93f284356 Support sys.pycache_prefix on py38
Fix #4730
2019-10-26 10:17:21 -03:00
Kale Kundert
b9df9a4761 Merge pull request #6058 from AnjoMan/6057-tolerance-on-complex-approx
6057 tolerance on complex approx
2019-10-25 15:31:47 -04:00
Bruno Oliveira
39066d5a42 Merge master into features (#6056)
Merge master into features
2019-10-25 16:27:14 -03:00
Anton Lodder
3c7fbe2d8b Document evaluating complex number for infinity 2019-10-25 12:03:03 -04:00
Michael Krebs
1f5b454355 Add log-auto-indent option to control multiline formatting 2019-10-25 11:31:33 -04:00
Daniel Hahler
82753bec50 terminal: report collection errors as "ERROR" in short summary 2019-10-25 07:03:32 +02:00
AnjoMan
34a02121ad Drop python 2 unicode tests for approx repr 2019-10-24 23:44:13 -04:00
AnjoMan
ed9fda84d3 Add tolerance to complex numbers 2019-10-24 23:44:13 -04:00
Bruno Oliveira
fb0e8b99d1 Merge remote-tracking branch 'upstream/master' into mm
Conflicts:
- 	src/_pytest/cacheprovider.py
2019-10-24 21:13:43 -03:00
Bruno Oliveira
d1bc2601e4 pytester: align prefixes (#6026)
pytester: align prefixes
2019-10-24 18:50:29 -03:00
Bruno Oliveira
73a77c90ca Change #5061 changelog to 'improvement' (#6051)
Change #5061 changelog to 'improvement'
2019-10-24 18:44:48 -03:00
Daniel Hahler
8ef4287bf0 pytester: align prefixes
This is important for using another match_nickname, e.g. "re.match".

TODO:

- [ ] changelog
- [ ] test
2019-10-24 23:20:12 +02:00
Daniel Hahler
45fc0d9cd8 Merge pull request #6040 from blueyed/test_meta-slow
tests: mark test_meta as slow
2019-10-24 22:53:04 +02:00
Bruno Oliveira
92418b8d5d Change #5061 changelog to 'improvement' 2019-10-23 21:27:07 -03:00
Bruno Oliveira
432e5550e5 assertrepr_compare: use safeformat with -vv (#5936)
assertrepr_compare: use safeformat with -vv
2019-10-23 19:51:40 -03:00
Daniel Hahler
8316d4392a Merge pull request #6028 from blueyed/DontReadFromInput-msg
capture: improve message with DontReadFromInput's IOError
2019-10-23 22:48:15 +02:00
Ran Benita
7a2d2d8f07 Merge pull request #5847 from bluetech/type-annotations-4
2/X Fix check_untyped_defs = True mypy errors
2019-10-23 22:52:23 +03:00
Daniel Hahler
6242777818 Merge pull request #6041 from blueyed/pytester-splitlines
pytester: runpytest_inprocess: use splitlines()
2019-10-23 21:42:21 +02:00
Bruno Oliveira
20ee883b5f Show the mnemonic of pytest.ExitCode in RunResult's repr (#6043)
Show the mnemonic of pytest.ExitCode in RunResult's repr
2019-10-23 10:46:58 -03:00
Bruno Oliveira
7beb520555 Show the mnemonic of pytest.ExitCode in RunResult's repr
Fix #4901
2019-10-23 09:16:02 -03:00
Ran Benita
1cc1ac5183 Remove some type: ignores fixed in typeshed 2019-10-23 14:47:56 +03:00
Ran Benita
1787bffda0 Fix check_untyped_defs errors in capture 2019-10-23 14:20:15 +03:00
Ran Benita
0267b25c66 Fix some check_untyped_defs mypy errors in terminal 2019-10-23 14:20:15 +03:00
Ran Benita
5dca7a2f4f Fix check_untyped_defs errors in cacheprovider 2019-10-23 14:20:15 +03:00
Ran Benita
93c8822f26 Fix check_untyped_defs errors in warnings 2019-10-23 14:20:15 +03:00
Ran Benita
583c2a2f9b Fix check_untyped_defs errors in logging 2019-10-23 14:20:15 +03:00
Ran Benita
1984c10427 Fix check_untyped_defs errors in doctest
In order to make the LiteralOutputChecker lazy initialization more
amenable to type checking, I changed it to match the scheme already used
in this file to lazy-initialize PytestDoctestRunner.
2019-10-23 14:20:14 +03:00
Ran Benita
3246d8a6e9 Merge pull request #6048 from bluetech/mypy-0.740
Update mypy 0.720 -> 0.740
2019-10-23 12:47:21 +03:00
Daniel Hahler
b30e7bd1de Merge pull request #6045 from blueyed/minor
minor: typing for ReprFailDoctest
2019-10-23 11:44:37 +02:00
Daniel Hahler
db9e248b2e Merge pull request #6039 from blueyed/test_doctest_id
doctest: unset RUNNER_CLASS in pytest_unconfigure
2019-10-23 11:38:59 +02:00
Daniel Hahler
1371b01f78 typing for ReprFailDoctest 2019-10-23 10:52:42 +02:00
Ran Benita
52b85f6f1a Update mypy 0.720 -> 0.740
Changelogs:
http://mypy-lang.blogspot.com/2019/09/mypy-730-released.html
http://mypy-lang.blogspot.com/2019/10/mypy-0740-released.html

New errors:
src/_pytest/recwarn.py:77: error: Missing return statement
src/_pytest/recwarn.py:185: error: "bool" is invalid as return type for "__exit__" that always returns False
src/_pytest/recwarn.py:185: note: Use "typing_extensions.Literal[False]" as the return type or change it to "None"
src/_pytest/recwarn.py:185: note: If return type of "__exit__" implies that it may return True, the context manager may swallow exceptions
src/_pytest/recwarn.py:185: error: Return type "bool" of "__exit__" incompatible with return type "None" in supertype "catch_warnings"
src/_pytest/recwarn.py:230: error: "bool" is invalid as return type for "__exit__" that always returns False
src/_pytest/recwarn.py:230: note: Use "typing_extensions.Literal[False]" as the return type or change it to "None"
src/_pytest/recwarn.py:230: note: If return type of "__exit__" implies that it may return True, the context manager may swallow exceptions
src/_pytest/recwarn.py:230: error: Return type "bool" of "__exit__" incompatible with return type "None" in supertype "catch_warnings"

The errors are due to this new error:
https://mypy.readthedocs.io/en/latest/error_code_list.html#check-the-return-type-of-exit-exit-return
2019-10-23 10:34:14 +03:00
Daniel Hahler
c71a2c9f80 Merge pull request #6023 from blueyed/main-exitcode
pytest.main: return ExitCode
2019-10-23 07:48:17 +02: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
Daniel Hahler
046aa0b6e9 pytest.main: return ExitCode 2019-10-23 04:33:05 +02:00
Daniel Hahler
f0c2b070c5 Merge pull request #6046 from blueyed/fix-features
Fix test_doctest_set_trace_quit on features
2019-10-23 04:32:10 +02:00
Daniel Hahler
b079dc2dbe Fix test_doctest_set_trace_quit on features 2019-10-23 04:13:37 +02:00
Daniel Hahler
4af89bba9d Merge pull request #5061 from blueyed/summary_stats-multi-color
Multiple colors with terminal summary_stats
2019-10-23 03:21:39 +02:00
Daniel Hahler
5e7b2ae704 doctest: pytest_unconfigure: reset RUNNER_CLASS
This is important when used with ``pytester``'s ``runpytest_inprocess``.

Since 07f20ccab `pytest testing/acceptance_test.py -k test_doctest_id`
would fail, since the second run would not consider the exception to be
an instance of `doctest.DocTestFailure` anymore, since the module was
re-imported, and use another failure message then in the short test
summary info (and in the report itself):

> FAILED test_doctest_id.txt::test_doctest_id.txt - doctest.DocTestFailure: <Do...

while it should be:

> FAILED test_doctest_id.txt::test_doctest_id.txt
2019-10-23 03:09:41 +02:00
Daniel Hahler
bae22e1fdd Merge pull request #6016 from blueyed/pytest-_ensure_unconfigure-twice
pytester: parseconfigure: remove duplicate config._ensure_unconfigure
2019-10-23 01:39:23 +02:00
Bruno Oliveira
215be88fed Minor: help / direct usage of config (#6011)
Minor: help / direct usage of config
2019-10-22 20:24:08 -03:00
Daniel Hahler
98fc9377d9 Merge pull request #5630 from blueyed/pdb-doctest-bdbquit
doctest: handle BdbQuit
2019-10-23 01:10:19 +02:00
Daniel Hahler
8683293031 Merge pull request #6017 from blueyed/DontReadFromInput-remove-comment
Remove (rejected) comment from DontReadFromInput
2019-10-23 01:07:12 +02:00
Daniel Hahler
bdadf12af1 Merge pull request #6030 from blueyed/tox-vv
ci: use tox -vv
2019-10-23 01:05:21 +02:00
Bruno Oliveira
a51bb3eedb Add CHANGELOG for #5630 2019-10-22 19:43:42 -03:00
Bruno Oliveira
f4734213e5 Merge remote-tracking branch 'upstream/features' into blueyed/pdb-doctest-bdbquit 2019-10-22 19:43:35 -03:00
Daniel Hahler
0dd68ba0b6 tests: mark test_meta as slow
This moves it to the end of tests during collection.  Takes ~7s for me.
2019-10-22 23:44:52 +02:00
Daniel Hahler
851fc0280f ci: Travis: configure/restrict branch builds [ci skip] 2019-10-22 23:03:31 +02:00
Daniel Hahler
56cec5fa79 ci: use tox -vv
This will display durations, and is useful in logs in general.
2019-10-22 05:46:52 +02:00
Daniel Hahler
3c14dd7f55 capture: improve message with DontReadFromInput's IOError
Ref: https://github.com/pytest-dev/pytest/pull/4996#issuecomment-479686487
2019-10-22 02:03:18 +02:00
Daniel Hahler
978c7ae1b7 Merge pull request #6015 from blueyed/merge-master-into-features
Merge master into features
2019-10-21 21:59:09 +02:00
Daniel Hahler
554dba391c Multiple colors with terminal summary_stats
Ref: https://github.com/pytest-dev/pytest/issues/5060
2019-10-21 04:35:45 +02:00
Daniel Hahler
995990c61b Remove (rejected) comment from DontReadFromInput
Ref: https://github.com/pytest-dev/pytest/pull/4996#issuecomment-479686487
2019-10-21 02:26:29 +02:00
Daniel Hahler
b47f57a08a pytester: parseconfigure: remove duplicate config._ensure_unconfigure
This gets done in `parseconfig` already.
2019-10-21 01:15:27 +02:00
Daniel Hahler
803cc1f294 Merge master into features 2019-10-21 00:08:03 +02:00
Daniel Hahler
46fbf22524 ci: Travis: cover verbose=1 2019-10-20 20:51:03 +02:00
Daniel Hahler
d91ff0af8a assertrepr_compare: use safeformat with -vv 2019-10-20 20:51:03 +02:00
Daniel Hahler
a6152db84a setuponly: pytest_fixture_setup: use option directly 2019-10-20 17:57:25 +02:00
Daniel Hahler
83351a3368 doc: improve help for filterwarnings 2019-10-20 17:56:59 +02:00
Daniel Hahler
fbb7f663be Merge pull request #6005 from blueyed/harden-trial
tests: harden/fix test_trial_error
2019-10-20 17:35:15 +02:00
Bruno Oliveira
b5579d2cf2 Make InvocationParams.args a tuple (#6008)
Make InvocationParams.args a tuple
2019-10-19 17:36:42 -03:00
Daniel Hahler
9b673bcc44 Improve/revisit CallInfo.__repr__ (#6007) 2019-10-19 21:45:27 +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
119bf66d7a ExceptionInfo.from_current: pass through exprinfo (#6002) 2019-10-19 19:20:55 +02:00
Daniel Hahler
15f9568694 Improve/revisit CallInfo.__repr__ 2019-10-19 19:07:11 +02:00
Daniel Hahler
5b88612e5b tests: harden/fix test_trial_error 2019-10-19 09:03:26 +02:00
Daniel Hahler
cd753aa4ab ExceptionInfo.from_current: pass through exprinfo
This was lost in 11f1f79222.
2019-10-19 03:02:47 +02:00
Daniel Hahler
94c4dd6ad7 help: display default verbosity (#5998) 2019-10-18 23:34:38 +02:00
Daniel Hahler
de7c1aa0b7 Merge pull request #5999 from blueyed/passenv-TERM
tox: pass $TERM
2019-10-18 23:34:03 +02:00
Daniel Hahler
ab245ccdc3 help: display default verbosity 2019-10-18 22:11:54 +02:00
Daniel Hahler
9da73541b7 tox: pass TERM
Ref: https://github.com/tox-dev/tox/issues/1441
2019-10-18 22:11:00 +02:00
Daniel Hahler
c9524af5ae Merge master into features (#5995) 2019-10-18 21:23:28 +02:00
Daniel Hahler
0976e2f50d Merge master into features 2019-10-18 17:51:42 +02:00
Bruno Oliveira
914a9465ab tests: move tests for setuponly/setupplan (#5961)
tests: move tests for setuponly/setupplan
2019-10-15 19:49:26 -03:00
Bruno Oliveira
f739d511b0 minor: test_failure_function: use vars (#5958)
minor: test_failure_function: use vars
2019-10-15 19:48:41 -03:00
Daniel Hahler
c2ae0e0dc6 tests: move tests for setuponly/setupplan
Forgotten in 032ce8baf.
2019-10-15 00:41:05 +02:00
Daniel Hahler
361f0e6ba7 minor: test_failure_function: use vars 2019-10-14 22:45:25 +02:00
Bruno Oliveira
afabbb6346 minor: test_assertion: improve mock_config (#5940)
minor: test_assertion: improve mock_config
2019-10-11 08:28:42 -03:00
Daniel Hahler
fb90259460 test_assertion: improve mock_config 2019-10-11 04:19:07 +02:00
Bruno Oliveira
db6653ce3b Improve ExceptionInfo.__repr__ (#5934)
Improve ExceptionInfo.__repr__
2019-10-09 17:08:55 -03:00
Daniel Hahler
2a2fe7d3db Improve ExceptionInfo.__repr__ 2019-10-09 19:27:46 +02:00
Bruno Oliveira
5c92a0f695 Merge master into features (#5930)
Merge master into features
2019-10-08 17:39:49 -03:00
Daniel Hahler
21c038f304 Merge master into features 2019-10-08 18:57:15 +02:00
Daniel Hahler
fca462cf7d Merge pull request #5924 from blueyed/improve-list-diff
Improve full diff output for lists
2019-10-08 17:58:25 +02:00
Daniel Hahler
946434c610 Improve full diff output for lists
Massage text input for difflib when comparing pformat output of
different line lengths.

Also do not strip ndiff output on the left, which currently already
removes indenting for lines with no differences.

Before:

    E   AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
    E     Right contains 3 more items, first extra item: ' '
    E     Full diff:
    E     - ['version', 'version_info', 'sys.version', 'sys.version_info']
    E     + ['version',
    E     +  'version_info',
    E     +  'sys.version',
    E     +  'sys.version_info',
    E     +  ' ',
    E     +  'sys.version',
    E     +  'sys.version_info']

After:

    E   AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
    E     Right contains 3 more items, first extra item: ' '
    E     Full diff:
    E       [
    E        'version',
    E        'version_info',
    E        'sys.version',
    E        'sys.version_info',
    E     +  ' ',
    E     +  'sys.version',
    E     +  'sys.version_info',
    E       ]
2019-10-08 15:27:51 +02:00
Bruno Oliveira
5186635387 Introduce no_fnmatch_line/no_re_match_line in pytester (#5914)
Introduce no_fnmatch_line/no_re_match_line in pytester
2019-10-06 20:27:20 -03:00
Daniel Hahler
cd398e289f Merge pull request #5920 from blueyed/lazy-import-pdb
Allow for "pdb" module to be rewritten
2019-10-06 23:46:11 +02:00
Bruno Oliveira
47c2091ecd Use new no-match functions to replace previous idiom 2019-10-06 18:05:24 -03:00
Bruno Oliveira
0c18e24433 Introduce no_fnmatch_line/no_re_match_line in pytester
The current idiom is to use:

  assert re.match(pat, result.stdout.str())

Or

  assert line in result.stdout.str()

But this does not really give good results when it fails.

Those new functions produce similar output to ther other match lines functions.
2019-10-06 18:05:24 -03:00
Daniel Hahler
07f20ccab6 Allow for "pdb" module to be rewritten 2019-10-06 23:02:24 +02:00
Daniel Hahler
b847d5712b Merge pull request #5923 from nicoddemus/mm
Merge master into features
2019-10-06 23:01:19 +02:00
Daniel Hahler
63d517645c doctest: handle BdbQuit
Map `BdbQuit` exception to `outcomes.Exit`.

This is necessary since we are not wrapping `pdb.set_trace` there, and
therefore our `do_quit` is not called.
2019-07-19 02:57:25 +02:00
221 changed files with 18894 additions and 11947 deletions

View File

@@ -24,3 +24,6 @@ exclude_lines =
\#\s*pragma: no cover
^\s*raise NotImplementedError\b
^\s*return NotImplemented\b
^\s*assert False(,|$)
^\s*if TYPE_CHECKING:

28
.gitblameignore Normal file
View File

@@ -0,0 +1,28 @@
# List of revisions that can be ignored with git-blame(1).
#
# See `blame.ignoreRevsFile` in git-config(1) to enable it by default, or
# use it with `--ignore-revs-file` manually with git-blame.
#
# To "install" it:
#
# git config --local blame.ignoreRevsFile .gitblameignore
# run black
703e4b11ba76171eccd3f13e723c47b810ded7ef
# switched to src layout
eaa882f3d5340956beb176aa1753e07e3f3f2190
# pre-commit run pyupgrade --all-files
a91fe1feddbded535a4322ab854429e3a3961fb4
# move node base classes from main to nodes
afc607cfd81458d4e4f3b1f3cf8cc931b933907e
# [?] split most fixture related code into own plugin
8c49561470708761f7321504f5e8343811be87ac
# run pyupgrade
9aacb4635e81edd6ecf281d4f6c0cfc8e94ab301
# run blacken-docs
5f95dce95602921a70bfbc7d8de2f7712c5e4505
# ran pyupgrade-docs again
75d0b899bbb56d6849e9d69d83a9426ed3f43f8b
# move argument parser to own file
c9df77cbd6a365dcb73c39618e4842711817e871

View File

@@ -2,15 +2,21 @@
Thanks for submitting a PR, your contribution is really appreciated!
Here is a quick checklist that should be present in PRs.
(please delete this text from the final description, this is just a guideline)
-->
- [ ] Target the `master` branch for bug fixes, documentation updates and trivial changes.
- [ ] Target the `features` branch for new features, improvements, and removals/deprecations.
- [ ] Include documentation when adding new features.
- [ ] Include new tests or update existing tests when applicable.
- [X] Allow maintainers to push and squash when merging my commits. Please uncheck this if you prefer to squash the commits yourself.
Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
- [ ] Create a new changelog file in the `changelog` folder, with a name like `<ISSUE NUMBER>.<TYPE>.rst`. See [changelog/README.rst](https://github.com/pytest-dev/pytest/blob/master/changelog/README.rst) for details.
- [ ] Add yourself to `AUTHORS` in alphabetical order;
Write sentences in the **past or present tense**, examples:
* *Improved verbose diff output with sequences.*
* *Terminal summary statistics now use multiple colors.*
Also make sure to end the sentence with a `.`.
- [ ] Add yourself to `AUTHORS` in alphabetical order.
-->

205
.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,205 @@
# evaluating GitHub actions for CI, disregard failures when evaluating PRs
#
# this is still missing:
# - deploy
# - upload github notes
#
name: main
on:
push:
branches:
- master
- "[0-9]+.[0-9]+.x"
tags:
- "*"
pull_request:
branches:
- master
- "[0-9]+.[0-9]+.x"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
name: [
"windows-py35",
"windows-py36",
"windows-py37",
"windows-py37-pluggy",
"windows-py38",
"ubuntu-py35",
"ubuntu-py36",
"ubuntu-py37",
"ubuntu-py37-pluggy",
"ubuntu-py37-freeze",
"ubuntu-py38",
"ubuntu-py39",
"ubuntu-pypy3",
"macos-py37",
"macos-py38",
"linting",
"docs",
"doctesting",
]
include:
- name: "windows-py35"
python: "3.5"
os: windows-latest
tox_env: "py35-xdist"
use_coverage: true
- name: "windows-py36"
python: "3.6"
os: windows-latest
tox_env: "py36-xdist"
- name: "windows-py37"
python: "3.7"
os: windows-latest
tox_env: "py37-numpy"
- name: "windows-py37-pluggy"
python: "3.7"
os: windows-latest
tox_env: "py37-pluggymaster-xdist"
- name: "windows-py38"
python: "3.8"
os: windows-latest
tox_env: "py38-unittestextras"
use_coverage: true
- name: "ubuntu-py35"
python: "3.5"
os: ubuntu-latest
tox_env: "py35-xdist"
- name: "ubuntu-py36"
python: "3.6"
os: ubuntu-latest
tox_env: "py36-xdist"
- name: "ubuntu-py37"
python: "3.7"
os: ubuntu-latest
tox_env: "py37-lsof-numpy-oldattrs-pexpect"
use_coverage: true
- name: "ubuntu-py37-pluggy"
python: "3.7"
os: ubuntu-latest
tox_env: "py37-pluggymaster-xdist"
- name: "ubuntu-py37-freeze"
python: "3.7"
os: ubuntu-latest
tox_env: "py37-freeze"
- name: "ubuntu-py38"
python: "3.8"
os: ubuntu-latest
tox_env: "py38-xdist"
- name: "ubuntu-py39"
python: "3.8"
os: ubuntu-latest
tox_env: "py39-xdist"
- name: "ubuntu-pypy3"
python: "pypy3"
os: ubuntu-latest
tox_env: "pypy3-xdist"
- name: "macos-py37"
python: "3.7"
os: macos-latest
tox_env: "py37-xdist"
- name: "macos-py38"
python: "3.8"
os: macos-latest
tox_env: "py38-xdist"
use_coverage: true
- name: "linting"
python: "3.7"
os: ubuntu-latest
tox_env: "linting"
- name: "docs"
python: "3.7"
os: ubuntu-latest
tox_env: "docs"
- name: "doctesting"
python: "3.7"
os: ubuntu-latest
tox_env: "doctesting"
use_coverage: true
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
- name: install python3.9
if: matrix.tox_env == 'py39-xdist'
run: |
sudo add-apt-repository ppa:deadsnakes/nightly
sudo apt-get update
sudo apt-get install -y --no-install-recommends python3.9-dev python3.9-distutils
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox coverage
- name: Test without coverage
if: "! matrix.use_coverage"
run: "tox -e ${{ matrix.tox_env }}"
- name: Test with coverage
if: "matrix.use_coverage"
env:
_PYTEST_TOX_COVERAGE_RUN: "coverage run -m"
COVERAGE_PROCESS_START: ".coveragerc"
_PYTEST_TOX_EXTRA_DEP: "coverage-enable-subprocess"
run: "tox -e ${{ matrix.tox_env }}"
- name: Prepare coverage token
if: (matrix.use_coverage && ( github.repository == 'pytest-dev/pytest' || github.event_name == 'pull_request' ))
run: |
python scripts/append_codecov_token.py
- name: Report coverage
if: (matrix.use_coverage)
env:
CODECOV_NAME: ${{ matrix.name }}
run: bash scripts/report-coverage.sh -F GHA,${{ runner.os }}
deploy:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'pytest-dev/pytest'
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel setuptools tox
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_token }}
- name: Publish GitHub release notes
env:
GH_RELEASE_NOTES_TOKEN: ${{ secrets.release_notes }}
run: |
sudo apt-get install pandoc
tox -e publish-gh-release-notes

View File

@@ -0,0 +1,28 @@
# part of our release process, see `release-on-comment.py`
name: release on comment
on:
issues:
types: [opened, edited]
issue_comment:
types: [created, edited]
jobs:
build:
runs-on: ubuntu-latest
if: (github.event.comment && startsWith(github.event.comment.body, '@pytestbot please')) || (github.event.issue && !github.event.comment && startsWith(github.event.issue.body, '@pytestbot please'))
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools tox
- name: Prepare release
run: |
tox -e release-on-comment -- $GITHUB_EVENT_PATH ${{ secrets.chatops }}

2
.gitignore vendored
View File

@@ -25,12 +25,14 @@ src/_pytest/_version.py
doc/*/_build
doc/*/.doctrees
doc/*/_changelog_towncrier_draft.rst
build/
dist/
*.egg-info
issue/
env/
.env/
.venv/
3rdparty/
.tox
.cache

View File

@@ -1,7 +1,6 @@
exclude: doc/en/example/py2py3/test_py2.py
repos:
- repo: https://github.com/psf/black
rev: 19.3b0
rev: 19.10b0
hooks:
- id: black
args: [--safe, --quiet]
@@ -9,7 +8,7 @@ repos:
rev: v1.0.0
hooks:
- id: blacken-docs
additional_dependencies: [black==19.3b0]
additional_dependencies: [black==19.10b0]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
@@ -37,12 +36,8 @@ repos:
hooks:
- id: pyupgrade
args: [--py3-plus]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.4.0
hooks:
- id: rst-backticks
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.720
rev: v0.761 # NOTE: keep this in sync with setup.py.
hooks:
- id: mypy
files: ^(src/|testing/)
@@ -52,14 +47,14 @@ repos:
- id: rst
name: rst
entry: rst-lint --encoding utf-8
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|TIDELIFT.rst|changelog/.*)$
files: ^(RELEASING.rst|README.rst|TIDELIFT.rst)$
language: python
additional_dependencies: [pygments, restructuredtext_lint]
- id: changelogs-rst
name: changelog filenames
language: fail
entry: 'changelog files must be named ####.(feature|bugfix|doc|deprecation|removal|vendor|trivial).rst'
exclude: changelog/(\d+\.(feature|improvement|bugfix|doc|deprecation|removal|vendor|trivial).rst|README.rst|_template.rst)
entry: 'changelog files must be named ####.(breaking|bugfix|deprecation|doc|feature|improvement|trivial|vendor).rst'
exclude: changelog/(\d+\.(breaking|bugfix|deprecation|doc|feature|improvement|trivial|vendor).rst|README.rst|_template.rst)
files: ^changelog/
- id: py-deprecated
name: py library is deprecated
@@ -69,7 +64,7 @@ repos:
_code\.|
builtin\.|
code\.|
io\.(BytesIO|saferepr)|
io\.(BytesIO|saferepr|TerminalWriter)|
path\.local\.sysfind|
process\.|
std\.

View File

@@ -1,12 +1,6 @@
language: python
dist: xenial
stages:
- baseline
- name: test
if: repo = pytest-dev/pytest AND tag IS NOT present
- name: deploy
if: repo = pytest-dev/pytest AND tag IS present
python: '3.7'
dist: trusty
python: '3.5.1'
cache: false
env:
@@ -22,77 +16,11 @@ install:
jobs:
include:
# OSX tests - first (in test stage), since they are the slower ones.
- os: osx
osx_image: xcode10.1
language: generic
env: TOXENV=py37-xdist PYTEST_COVERAGE=1
# Coverage for Python 3.5.{0,1} specific code, mostly typing related.
- env: TOXENV=py35 PYTEST_COVERAGE=1 PYTEST_ADDOPTS="-k test_raises_cyclic_reference"
before_install:
- which python3
- python3 -V
- ln -sfn "$(which python3)" /usr/local/bin/python
- python -V
- test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37
# Full run of latest supported version, without xdist.
# Coverage for:
# - test_sys_breakpoint_interception (via pexpect).
- env: TOXENV=py37-pexpect PYTEST_COVERAGE=1
python: '3.7'
# Coverage tracking is slow with pypy, skip it.
- env: TOXENV=pypy3-xdist
python: 'pypy3'
- env: TOXENV=py35-xdist
python: '3.5'
# Coverage for:
# - pytester's LsofFdLeakChecker
# - TestArgComplete (linux only)
# - numpy
# - old attrs
# Empty PYTEST_ADDOPTS to run this non-verbose.
- env: TOXENV=py37-lsof-oldattrs-numpy-twisted-xdist PYTEST_COVERAGE=1 PYTEST_ADDOPTS=
# Specialized factors for py37.
- env: TOXENV=py37-pluggymaster-xdist
- env: TOXENV=py37-freeze
- env: TOXENV=py38-xdist
python: '3.8'
- stage: baseline
env: TOXENV=py36-xdist
python: '3.6'
- env: TOXENV=linting,docs,doctesting PYTEST_COVERAGE=1
cache:
directories:
- $HOME/.cache/pre-commit
- stage: deploy
python: '3.6'
install: pip install -U setuptools setuptools_scm tox
script: skip
# token to upload github release notes: GH_RELEASE_NOTES_TOKEN
env:
- secure: "OjOeL7/0JUDkV00SsTs732e8vQjHynpbG9FKTNtZZJ+1Zn4Cib+hAlwmlBnvVukML0X60YpcfjnC4quDOIGLPsh5zeXnvJmYtAIIUNQXjWz8NhcGYrhyzuP1rqV22U68RTCdmOq3lMYU/W2acwHP7T49PwJtOiUM5kF120UAQ0Zi5EmkqkIvH8oM5mO9Dlver+/U7Htpz9rhKrHBXQNCMZI6yj2aUyukqB2PN2fjAlDbCF//+FmvYw9NjT4GeFOSkTCf4ER9yfqs7yglRfwiLtOCZ2qKQhWZNsSJDB89rxIRXWavJUjJKeY2EW2/NkomYJDpqJLIF4JeFRw/HhA47CYPeo6BJqyyNV+0CovL1frpWfi9UQw2cMbgFUkUIUk3F6DD59PHNIOX2R/HX56dQsw7WKl3QuHlCOkICXYg8F7Ta684IoKjeTX03/6QNOkURfDBwfGszY0FpbxrjCSWKom6RyZdyidnESaxv9RzjcIRZVh1rp8KMrwS1OrwRSdG0zjlsPr49hWMenN/8fKgcHTV4/r1Tj6mip0dorSRCrgUNIeRBKgmui6FS8642ab5JNKOxMteVPVR2sFuhjOQ0Jy+PmvceYY9ZMWc3+/B/KVh0dZ3hwvLGZep/vxDS2PwCA5/xw31714vT5LxidKo8yECjBynMU/wUTTS695D3NY="
addons:
apt:
packages:
# required by publish_gh_release_notes
- pandoc
after_deploy: tox -e publish_gh_release_notes
deploy:
provider: pypi
user: nicoddemus
distributions: sdist bdist_wheel
skip_upload_docs: true
password:
secure: xanTgTUu6XDQVqB/0bwJQXoDMnU5tkwZc5koz6mBkkqZhKdNOi2CLoC1XhiSZ+ah24l4V1E0GAqY5kBBcy9d7NVe4WNg4tD095LsHw+CRU6/HCVIFfyk2IZ+FPAlguesCcUiJSXOrlBF+Wj68wEvLoK7EoRFbJeiZ/f91Ww1sbtDlqXABWGHrmhPJL5Wva7o7+wG7JwJowqdZg1pbQExsCc7b53w4v2RBu3D6TJaTAzHiVsW+nUSI67vKI/uf+cR/OixsTfy37wlHgSwihYmrYLFls3V0bSpahCim3bCgMaFZx8S8xrdgJ++PzBCof2HeflFKvW+VCkoYzGEG4NrTWJoNz6ni4red9GdvfjGH3YCjAKS56h9x58zp2E5rpsb/kVq5/45xzV+dq6JRuhQ1nJWjBC6fSKAc/bfwnuFK3EBxNLkvBssLHvsNjj5XG++cB8DdS9wVGUqjpoK4puaXUWFqy4q3S9F86HEsKNgExtieA9qNx+pCIZVs6JCXZNjr0I5eVNzqJIyggNgJG6RyravsU35t9Zd9doL5g4Y7UKmAGTn1Sz24HQ4sMQgXdm2SyD8gEK5je4tlhUvfGtDvMSlstq71kIn9nRpFnqB6MFlbYSEAZmo8dGbCquoUc++6Rum208wcVbrzzVtGlXB/Ow9AbFMYeAGA0+N/K1e59c=
on:
tags: true
repo: pytest-dev/pytest
# Work around https://github.com/jaraco/zipp/issues/40.
- python -m pip install -U 'setuptools>=34.4.0' virtualenv==16.7.9
before_script:
- |
@@ -113,7 +41,7 @@ script: tox
after_success:
- |
if [[ "$PYTEST_COVERAGE" = 1 ]]; then
env CODECOV_NAME="$TOXENV-$TRAVIS_OS_NAME" scripts/report-coverage.sh
env CODECOV_NAME="$TOXENV-$TRAVIS_OS_NAME" scripts/report-coverage.sh -F Travis
fi
notifications:
@@ -125,3 +53,8 @@ notifications:
skip_join: true
email:
- pytest-commit@python.org
branches:
only:
- master
- /^\d+\.\d+\.x$/

24
AUTHORS
View File

@@ -52,6 +52,7 @@ Carl Friedrich Bolz
Carlos Jenkins
Ceridwen
Charles Cloud
Charles Machalow
Charnjit SiNGH (CCSJ)
Chris Lamb
Christian Boelsen
@@ -59,12 +60,13 @@ Christian Fetzer
Christian Neumüller
Christian Theunert
Christian Tismer
Christopher Gilling
Christoph Buelter
Christopher Dignam
Christopher Gilling
Claudio Madotto
CrazyMerlyn
Cyrus Maden
Damian Skrzypczak
Dhiren Serai
Daniel Grana
Daniel Hahler
Daniel Nuri
@@ -79,6 +81,7 @@ David Szotten
David Vierra
Daw-Ran Liou
Denis Kirisov
Dhiren Serai
Diego Russo
Dmitry Dygalo
Dmitry Pribysh
@@ -104,12 +107,14 @@ George Kussumoto
Georgy Dyuldin
Graham Horler
Greg Price
Gregory Lee
Grig Gheorghiu
Grigorii Eremeev (budulianin)
Guido Wesdorp
Guoqiang Zhang
Harald Armin Massa
Henk-Jaap Wagenaar
Holger Kohr
Hugo van Kemenade
Hui Wang (coldnight)
Ian Bicking
@@ -118,6 +123,7 @@ Ilya Konstantinov
Ionuț Turturică
Iwan Briquemont
Jaap Broekhuizen
Jakub Mitoraj
Jan Balster
Janne Vanhala
Jason R. Coombs
@@ -134,10 +140,12 @@ Jordan Guymon
Jordan Moldow
Jordan Speicher
Joseph Hunkeler
Josh Karpel
Joshua Bronson
Jurko Gospodnetić
Justyna Janczyszyn
Kale Kundert
Karl O. Pinc
Katarzyna Jachim
Katerina Koukiou
Kevin Cox
@@ -161,7 +169,9 @@ Manuel Krebber
Marc Schlaich
Marcelo Duarte Trevisani
Marcin Bachry
Marco Gorelli
Mark Abramowitz
Mark Dickinson
Markus Unterwaditzer
Martijn Faassen
Martin Altmayer
@@ -178,12 +188,14 @@ Michael Aquilina
Michael Birtwell
Michael Droettboom
Michael Goerz
Michael Krebs
Michael Seifert
Michal Wajszczuk
Mihai Capotă
Mike Hoyle (hoylemd)
Mike Lundy
Miro Hrončok
Nathaniel Compton
Nathaniel Waisbrot
Ned Batchelder
Neven Mundar
@@ -200,8 +212,10 @@ Omer Hadari
Ondřej Súkup
Oscar Benjamin
Patrick Hayes
Pauli Virtanen
Paweł Adamczak
Pedro Algarvio
Philipp Loose
Pieter Mulder
Piotr Banaszkiewicz
Pulkit Goyal
@@ -229,10 +243,12 @@ Samuele Pedroni
Sankt Petersbug
Segev Finer
Serhii Mozghovyi
Seth Junot
Simon Gomizelj
Skylar Downes
Srinivas Reddy Thatiparthy
Stefan Farmbauer
Stefan Scherfke
Stefan Zimmermann
Stefano Taschini
Steffen Allner
@@ -249,7 +265,9 @@ Tim Hoffmann
Tim Strazny
Tom Dalton
Tom Viner
Tomáš Gavenčiak
Tomer Keren
Tor Colvin
Trevor Bekolay
Tyler Goodlet
Tzu-ping Chung
@@ -260,7 +278,9 @@ Vidar T. Fauske
Virgil Dupras
Vitaly Lashmanov
Vlad Dragos
Vladyslav Rachek
Volodymyr Piskun
Wei Lin
Wil Cooley
William Lee
Wim Glenn

File diff suppressed because it is too large Load Diff

View File

@@ -71,7 +71,6 @@ contacted individually:
- Brianna Laugher ([@pfctdayelise](https://github.com/pfctdayelise)): brianna@laugher.id.au
- Bruno Oliveira ([@nicoddemus](https://github.com/nicoddemus)): nicoddemus@gmail.com
- Florian Bruhin ([@the-compiler](https://github.com/the-compiler)): pytest@the-compiler.org
- Ronny Pfannschmidt ([@RonnyPfannschmidt](https://github.com/RonnyPfannschmidt)): ich@ronnypfannschmidt.de
## Attribution

View File

@@ -51,7 +51,8 @@ Fix bugs
Look through the `GitHub issues for bugs <https://github.com/pytest-dev/pytest/labels/type:%20bug>`_.
:ref:`Talk <contact>` to developers to find out how you can fix specific bugs.
:ref:`Talk <contact>` to developers to find out how you can fix specific bugs. To indicate that you are going
to work on a particular issue, add a comment to that effect on the specific issue.
Don't forget to check the issue trackers of your favourite plugins, too!
@@ -85,7 +86,7 @@ without using a local copy. This can be convenient for small fixes.
$ tox -e docs
The built documentation should be available in the ``doc/en/_build/``.
The built documentation should be available in ``doc/en/_build/html``.
Where 'en' refers to the documentation language.
@@ -165,8 +166,6 @@ Short version
#. Fork the repository.
#. Enable and install `pre-commit <https://pre-commit.com>`_ to ensure style-guides and code checks are followed.
#. Target ``master`` for bugfixes and doc changes.
#. Target ``features`` for new features or functionality changes.
#. Follow **PEP-8** for naming and `black <https://github.com/psf/black>`_ for formatting.
#. Tests are run using ``tox``::
@@ -203,15 +202,11 @@ Here is a simple overview, with pytest-specific bits:
$ git clone git@github.com:YOUR_GITHUB_USERNAME/pytest.git
$ cd pytest
# now, to fix a bug create your own branch off "master":
# now, create your own branch off "master":
$ git checkout -b your-bugfix-branch-name master
# or to instead add a feature create your own branch off "features":
$ git checkout -b your-feature-branch-name features
Given we have "major.minor.micro" version numbers, bugfixes will usually
Given we have "major.minor.micro" version numbers, bug fixes will usually
be released in micro releases whereas features will be released in
minor releases and incompatible changes in major releases.
@@ -262,6 +257,19 @@ Here is a simple overview, with pytest-specific bits:
When committing, ``pre-commit`` will re-format the files if necessary.
#. If instead of using ``tox`` you prefer to run the tests directly, then we suggest to create a virtual environment and use
an editable install with the ``testing`` extra::
$ python3 -m venv .venv
$ source .venv/bin/activate # Linux
$ .venv/Scripts/activate.bat # Windows
$ pip install -e ".[testing]"
Afterwards, you can edit the files and run pytest normally::
$ pytest testing/test_config.py
#. Commit and push once your tests pass and you are happy with your change(s)::
$ git commit -a -m "<commit message>"
@@ -280,8 +288,7 @@ Here is a simple overview, with pytest-specific bits:
compare: your-branch-name
base-fork: pytest-dev/pytest
base: master # if it's a bugfix
base: features # if it's a feature
base: master
Writing Tests

View File

@@ -1,60 +0,0 @@
Release Procedure
-----------------
Our current policy for releasing is to aim for a bugfix every few weeks and a minor release every 2-3 months. The idea
is to get fixes and new features out instead of trying to cram a ton of features into a release and by consequence
taking a lot of time to make a new one.
.. important::
pytest releases must be prepared on **Linux** because the docs and examples expect
to be executed in that platform.
#. Create a branch ``release-X.Y.Z`` with the version for the release.
* **maintenance releases**: from ``4.6-maintenance``;
* **patch releases**: from the latest ``master``;
* **minor releases**: from the latest ``features``; then merge with the latest ``master``;
Ensure your are in a clean work tree.
#. Using ``tox``, generate docs, changelog, announcements::
$ tox -e release -- <VERSION>
This will generate a commit with all the changes ready for pushing.
#. Open a PR for this branch targeting ``master`` (or ``4.6-maintenance`` for
maintenance releases).
#. After all tests pass and the PR has been approved, publish to PyPI by pushing the tag::
git tag <VERSION>
git push git@github.com:pytest-dev/pytest.git <VERSION>
Wait for the deploy to complete, then make sure it is `available on PyPI <https://pypi.org/project/pytest>`_.
#. Merge the PR.
#. If this is a maintenance release, cherry-pick the CHANGELOG / announce
files to the ``master`` branch::
git fetch --all --prune
git checkout origin/master -b cherry-pick-maintenance-release
git cherry-pick --no-commit -m1 origin/4.6-maintenance
git checkout origin/master -- changelog
git commit # no arguments
#. Send an email announcement with the contents from::
doc/en/announce/release-<VERSION>.rst
To the following mailing lists:
* pytest-dev@python.org (all releases)
* python-announce-list@python.org (all releases)
* testing-in-python@lists.idyll.org (only major/minor releases)
And announce it on `Twitter <https://twitter.com/>`_ with the ``#pytest`` hashtag.

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2004-2019 Holger Krekel and others
Copyright (c) 2004-2020 Holger Krekel and others
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View File

@@ -31,6 +31,10 @@
.. image:: https://www.codetriage.com/pytest-dev/pytest/badges/users.svg
:target: https://www.codetriage.com/pytest-dev/pytest
.. image:: https://readthedocs.org/projects/pytest/badge/?version=latest
:target: https://pytest.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
The ``pytest`` framework makes it easy to write small tests, yet
scales to support complex functional testing for applications and libraries.
@@ -112,12 +116,12 @@ Support pytest
--------------
`Open Collective`_ is an online funding platform for open and transparent communities.
It provide tools to raise money and share your finances in full transparency.
It provides tools to raise money and share your finances in full transparency.
It is the platform of choice for individuals and companies that want to make one-time or
monthly donations directly to the project.
See more datails in the `pytest collective`_.
See more details in the `pytest collective`_.
.. _Open Collective: https://opencollective.com
.. _pytest collective: https://opencollective.com/pytest
@@ -137,7 +141,7 @@ Save time, reduce risk, and improve code health, while paying the maintainers of
Security
^^^^^^^^
pytest has never been associated with a security vunerability, but in any case, to report a
pytest has never been associated with a security vulnerability, but in any case, to report a
security vulnerability please use the `Tidelift security contact <https://tidelift.com/security>`_.
Tidelift will coordinate the fix and disclosure.
@@ -145,7 +149,7 @@ Tidelift will coordinate the fix and disclosure.
License
-------
Copyright Holger Krekel and others, 2004-2019.
Copyright Holger Krekel and others, 2004-2020.
Distributed under the terms of the `MIT`_ license, pytest is free and open source software.

82
RELEASING.rst Normal file
View File

@@ -0,0 +1,82 @@
Release Procedure
-----------------
Our current policy for releasing is to aim for a bug-fix release every few weeks and a minor release every 2-3 months. The idea
is to get fixes and new features out instead of trying to cram a ton of features into a release and by consequence
taking a lot of time to make a new one.
Preparing: Automatic Method
~~~~~~~~~~~~~~~~~~~~~~~~~~~
We have developed an automated workflow for releases, that uses GitHub workflows and is triggered
by opening an issue or issuing a comment one.
The comment must be in the form::
@pytestbot please prepare release from BRANCH
Where ``BRANCH`` is ``master`` or one of the maintenance branches.
After that, the workflow should publish a PR and notify that it has done so as a comment
in the original issue.
Preparing: Manual Method
~~~~~~~~~~~~~~~~~~~~~~~~
.. important::
pytest releases must be prepared on **Linux** because the docs and examples expect
to be executed on that platform.
To release a version ``MAJOR.MINOR.PATCH``, follow these steps:
#. For major and minor releases, create a new branch ``MAJOR.MINOR.x`` from the
latest ``master`` and push it to the ``pytest-dev/pytest`` repo.
#. Create a branch ``release-MAJOR.MINOR.PATCH`` from the ``MAJOR.MINOR.x`` branch.
Ensure your are updated and in a clean working tree.
#. Using ``tox``, generate docs, changelog, announcements::
$ tox -e release -- MAJOR.MINOR.PATCH
This will generate a commit with all the changes ready for pushing.
#. Open a PR for the ``release-MAJOR.MINOR.PATCH`` branch targeting ``MAJOR.MINOR.x``.
Releasing
~~~~~~~~~
Both automatic and manual processes described above follow the same steps from this point onward.
#. After all tests pass and the PR has been approved, tag the release commit
in the ``MAJOR.MINOR.x`` branch and push it. This will publish to PyPI::
git tag MAJOR.MINOR.PATCH
git push git@github.com:pytest-dev/pytest.git MAJOR.MINOR.PATCH
Wait for the deploy to complete, then make sure it is `available on PyPI <https://pypi.org/project/pytest>`_.
#. Merge the PR.
#. Cherry-pick the CHANGELOG / announce files to the ``master`` branch::
git fetch --all --prune
git checkout origin/master -b cherry-pick-release
git cherry-pick --no-commit -m1 origin/MAJOR.MINOR.x
git checkout origin/master -- changelog
git commit # no arguments
#. Send an email announcement with the contents from::
doc/en/announce/release-<VERSION>.rst
To the following mailing lists:
* pytest-dev@python.org (all releases)
* python-announce-list@python.org (all releases)
* testing-in-python@lists.idyll.org (only major/minor releases)
And announce it on `Twitter <https://twitter.com/>`_ with the ``#pytest`` hashtag.

View File

@@ -1,77 +0,0 @@
trigger:
- master
- features
variables:
PYTEST_ADDOPTS: "--junitxml=build/test-results/$(tox.env).xml -vv"
PYTEST_COVERAGE: '0'
jobs:
- job: 'Test'
pool:
vmImage: "vs2017-win2016"
strategy:
matrix:
# -- pypy3 disabled for now: #5279 --
# pypy3:
# python.version: 'pypy3'
# tox.env: 'pypy3'
py35-xdist:
python.version: '3.5'
tox.env: 'py35-xdist'
# Coverage for:
# - test_supports_breakpoint_module_global
PYTEST_COVERAGE: '1'
py36-xdist:
python.version: '3.6'
tox.env: 'py36-xdist'
py37:
python.version: '3.7'
tox.env: 'py37-twisted-numpy'
# Coverage for:
# - _py36_windowsconsoleio_workaround (with py36+)
# - test_request_garbage (no xdist)
PYTEST_COVERAGE: '1'
py37-linting/docs/doctesting:
python.version: '3.7'
tox.env: 'linting,docs,doctesting'
py37-pluggymaster-xdist:
python.version: '3.7'
tox.env: 'py37-pluggymaster-xdist'
maxParallel: 10
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'
- script: python -m pip install --upgrade pip && python -m pip install tox
displayName: 'Install tox'
- bash: |
if [[ "$PYTEST_COVERAGE" == "1" ]]; then
export _PYTEST_TOX_COVERAGE_RUN="coverage run -m"
export _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess
export COVERAGE_FILE="$PWD/.coverage"
export COVERAGE_PROCESS_START="$PWD/.coveragerc"
fi
python -m tox -e $(tox.env)
displayName: 'Run tests'
- task: PublishTestResults@2
inputs:
testResultsFiles: 'build/test-results/$(tox.env).xml'
testRunTitle: '$(tox.env)'
condition: succeededOrFailed()
- bash: |
if [[ "$PYTEST_COVERAGE" == 1 ]]; then
scripts/report-coverage.sh
fi
env:
CODECOV_NAME: $(tox.env)
CODECOV_TOKEN: $(CODECOV_TOKEN)
displayName: Report and upload coverage
condition: eq(variables['PYTEST_COVERAGE'], '1')

View File

@@ -1,22 +1,24 @@
This directory contains "newsfragments" which are short files that contain a small **ReST**-formatted
text that will be added to the next ``CHANGELOG``.
The ``CHANGELOG`` will be read by users, so this description should be aimed to pytest users
The ``CHANGELOG`` will be read by **users**, so this description should be aimed to pytest users
instead of describing internal changes which are only relevant to the developers.
Make sure to use full sentences with correct case and punctuation, for example::
Make sure to use full sentences in the **past or present tense** and use punctuation, examples::
Fix issue with non-ascii messages from the ``warnings`` module.
Improved verbose diff output with sequences.
Terminal summary statistics now use multiple colors.
Each file should be named like ``<ISSUE>.<TYPE>.rst``, where
``<ISSUE>`` is an issue number, and ``<TYPE>`` is one of:
* ``feature``: new user facing features, like new command-line options and new behavior.
* ``improvement``: improvement of existing functionality, usually without requiring user intervention (for example, new fields being written in ``--junitxml``, improved colors in terminal, etc).
* ``bugfix``: fixes a reported bug.
* ``bugfix``: fixes a bug.
* ``doc``: documentation improvement, like rewording an entire session or adding missing docs.
* ``deprecation``: feature deprecation.
* ``removal``: feature removal.
* ``breaking``: a change which may break existing suites, such as feature removal or behavior change.
* ``vendor``: changes in packages vendored in pytest.
* ``trivial``: fixing a small typo or internal change that might be noteworthy.
@@ -29,6 +31,7 @@ changelog using that instead.
If you are not sure what issue type to use, don't hesitate to ask in your PR.
``towncrier`` preserves multiple paragraphs and formatting (code blocks, lists, and so on), but for entries
other than ``features`` it is usually better to stick to a single paragraph to keep it concise. You can install
``towncrier`` and then run ``towncrier --draft``
if you want to get a preview of how your change will look in the final release notes.
other than ``features`` it is usually better to stick to a single paragraph to keep it concise.
You can also run ``tox -e docs`` to build the documentation
with the draft changelog (``doc/en/_build/html/changelog.html``) if you want to get a preview of how your change will look in the final release notes.

View File

@@ -1,7 +1,6 @@
# reference: https://docs.codecov.io/docs/codecovyml-reference
coverage:
status:
project: true
patch: true
changes: true
comment: off
project: false
comment: false

View File

@@ -1,16 +1,24 @@
# Makefile for Sphinx documentation
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
REGENDOC_ARGS := \
--normalize "/[ \t]+\n/\n/" \
@@ -25,130 +33,8 @@ REGENDOC_ARGS := \
--normalize "@hypothesis-(\d+)\\.[.\d,]+@hypothesis-\1.x.y@" \
--normalize "@Python (\d+)\\.[^ ,]+@Python \1.x.y@"
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " showtarget to show the pytest.org target directory"
@echo " install to install docs to pytest.org/SITETARGET"
@echo " install-ldf to install the doc pdf to pytest.org/SITETARGET"
@echo " regen to regenerate pytest examples using the installed pytest"
@echo " linkcheck to check all external links for integrity"
clean:
-rm -rf $(BUILDDIR)/*
regen: REGENDOC_FILES:=*.rst */*.rst
regen:
PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS="-pno:hypothesis -Wignore::pytest.PytestUnknownMarkWarning" COLUMNS=76 regendoc --update ${REGENDOC_FILES} ${REGENDOC_ARGS}
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pytest.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pytest.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/pytest"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pytest"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
make -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
texinfo:
mkdir -p $(BUILDDIR)/texinfo
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
mkdir -p $(BUILDDIR)/texinfo
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
.PHONY: regen

View File

@@ -21,3 +21,7 @@
<hr>
{{ toc }}
{%- endif %}
<hr>
<a href="{{ pathto('genindex') }}">Index</a>
<hr>

View File

@@ -1,20 +0,0 @@
{% extends "!layout.html" %}
{% block header %}
{{super()}}
{% endblock %}
{% block footer %}
{{ super() }}
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-7597274-13']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
{% endblock %}

View File

@@ -6,6 +6,17 @@ Release announcements
:maxdepth: 2
release-5.4.3
release-5.4.2
release-5.4.1
release-5.4.0
release-5.3.5
release-5.3.4
release-5.3.3
release-5.3.2
release-5.3.1
release-5.3.0
release-5.2.4
release-5.2.3
release-5.2.2
release-5.2.1
@@ -16,6 +27,10 @@ Release announcements
release-5.1.0
release-5.0.1
release-5.0.0
release-4.6.9
release-4.6.8
release-4.6.7
release-4.6.6
release-4.6.5
release-4.6.4
release-4.6.3

View File

@@ -7,7 +7,7 @@ see below for summary and detailed lists. A lot of long-deprecated code
has been removed, resulting in a much smaller and cleaner
implementation. See the new docs with examples here:
http://pytest.org/2.0.0/index.html
http://pytest.org/en/latest/index.html
A note on packaging: pytest used to part of the "py" distribution up
until version py-1.3.4 but this has changed now: pytest-2.0.0 only
@@ -36,12 +36,12 @@ New Features
import pytest ; pytest.main(arglist, pluginlist)
see http://pytest.org/2.0.0/usage.html for details.
see http://pytest.org/en/latest/usage.html for details.
- new and better reporting information in assert expressions
if comparing lists, sequences or strings.
see http://pytest.org/2.0.0/assert.html#newreport
see http://pytest.org/en/latest/assert.html#newreport
- new configuration through ini-files (setup.cfg or tox.ini recognized),
for example::
@@ -50,7 +50,7 @@ New Features
norecursedirs = .hg data* # don't ever recurse in such dirs
addopts = -x --pyargs # add these command line options by default
see http://pytest.org/2.0.0/customize.html
see http://pytest.org/en/latest/customize.html
- improved standard unittest support. In general py.test should now
better be able to run custom unittest.TestCases like twisted trial

View File

@@ -57,7 +57,7 @@ Changes between 2.0.0 and 2.0.1
- refinements to "collecting" output on non-ttys
- refine internal plugin registration and --traceconfig output
- introduce a mechanism to prevent/unregister plugins from the
command line, see http://pytest.org/latest/plugins.html#cmdunregister
command line, see http://pytest.org/en/latest/plugins.html#cmdunregister
- activate resultlog plugin by default
- fix regression wrt yielded tests which due to the
collection-before-running semantics were not

View File

@@ -9,7 +9,7 @@ with these improvements:
- new @pytest.mark.parametrize decorator to run tests with different arguments
- new metafunc.parametrize() API for parametrizing arguments independently
- see examples at http://pytest.org/latest/example/parametrize.html
- see examples at http://pytest.org/en/latest/example/parametrize.html
- NOTE that parametrize() related APIs are still a bit experimental
and might change in future releases.
@@ -18,7 +18,7 @@ with these improvements:
- "-m markexpr" option for selecting tests according to their mark
- a new "markers" ini-variable for registering test markers for your project
- the new "--strict" bails out with an error if using unregistered markers.
- see examples at http://pytest.org/latest/example/markers.html
- see examples at http://pytest.org/en/latest/example/markers.html
* duration profiling: new "--duration=N" option showing the N slowest test
execution or setup/teardown calls. This is most useful if you want to
@@ -78,7 +78,7 @@ Changes between 2.1.3 and 2.2.0
or through plugin hooks. Also introduce a "--strict" option which
will treat unregistered markers as errors
allowing to avoid typos and maintain a well described set of markers
for your test suite. See examples at http://pytest.org/latest/mark.html
for your test suite. See examples at http://pytest.org/en/latest/mark.html
and its links.
- issue50: introduce "-m marker" option to select tests based on markers
(this is a stricter and more predictable version of "-k" in that "-m"

View File

@@ -3,22 +3,22 @@ pytest-2.3: improved fixtures / better unittest integration
pytest-2.3 comes with many major improvements for fixture/funcarg management
and parametrized testing in Python. It is now easier, more efficient and
more predicatable to re-run the same tests with different fixture
more predictable to re-run the same tests with different fixture
instances. Also, you can directly declare the caching "scope" of
fixtures so that dependent tests throughout your whole test suite can
re-use database or other expensive fixture objects with ease. Lastly,
it's possible for fixture functions (formerly known as funcarg
factories) to use other fixtures, allowing for a completely modular and
re-useable fixture design.
re-usable fixture design.
For detailed info and tutorial-style examples, see:
http://pytest.org/latest/fixture.html
http://pytest.org/en/latest/fixture.html
Moreover, there is now support for using pytest fixtures/funcargs with
unittest-style suites, see here for examples:
http://pytest.org/latest/unittest.html
http://pytest.org/en/latest/unittest.html
Besides, more unittest-test suites are now expected to "simply work"
with pytest.
@@ -29,11 +29,11 @@ pytest-2.2.4.
If you are interested in the precise reasoning (including examples) of the
pytest-2.3 fixture evolution, please consult
http://pytest.org/latest/funcarg_compare.html
http://pytest.org/en/latest/funcarg_compare.html
For general info on installation and getting started:
http://pytest.org/latest/getting-started.html
http://pytest.org/en/latest/getting-started.html
Docs and PDF access as usual at:
@@ -94,7 +94,7 @@ Changes between 2.2.4 and 2.3.0
- pluginmanager.register(...) now raises ValueError if the
plugin has been already registered or the name is taken
- fix issue159: improve http://pytest.org/latest/faq.html
- fix issue159: improve http://pytest.org/en/latest/faq.html
especially with respect to the "magic" history, also mention
pytest-django, trial and unittest integration.

View File

@@ -16,7 +16,7 @@ comes with the following fixes and features:
- yielded test functions will now have autouse-fixtures active but
cannot accept fixtures as funcargs - it's anyway recommended to
rather use the post-2.0 parametrize features instead of yield, see:
http://pytest.org/latest/example/parametrize.html
http://pytest.org/en/latest/example/parametrize.html
- fix autouse-issue where autouse-fixtures would not be discovered
if defined in an a/conftest.py file and tests in a/tests/test_some.py
- fix issue226 - LIFO ordering for fixture teardowns

View File

@@ -7,7 +7,7 @@ from a few supposedly very minor incompatibilities. See below for
a full list of details. A few feature highlights:
- new yield-style fixtures `pytest.yield_fixture
<http://pytest.org/latest/yieldfixture.html>`_, allowing to use
<http://pytest.org/en/latest/yieldfixture.html>`_, allowing to use
existing with-style context managers in fixture functions.
- improved pdb support: ``import pdb ; pdb.set_trace()`` now works

View File

@@ -91,7 +91,7 @@ holger krekel
it might be the cause for other finalizers to fail.
- fix ordering when mock.patch or other standard decorator-wrappings
are used with test methods. This fixues issue346 and should
are used with test methods. This fixes issue346 and should
help with random "xdist" collection failures. Thanks to
Ronny Pfannschmidt and Donald Stufft for helping to isolate it.

View File

@@ -35,7 +35,7 @@ holger krekel
- fix issue435: make reload() work when assert rewriting is active.
Thanks Daniel Hahler.
- fix issue616: conftest.py files and their contained fixutres are now
- fix issue616: conftest.py files and their contained fixtures are now
properly considered for visibility, independently from the exact
current working directory and test arguments that are used.
Many thanks to Eric Siegerman and his PR235 which contains
@@ -52,7 +52,7 @@ holger krekel
- add ability to set command line options by environment variable PYTEST_ADDOPTS.
- added documentation on the new pytest-dev teams on bitbucket and
github. See https://pytest.org/latest/contributing.html .
github. See https://pytest.org/en/latest/contributing.html .
Thanks to Anatoly for pushing and initial work on this.
- fix issue650: new option ``--docttest-ignore-import-errors`` which

View File

@@ -131,7 +131,7 @@ The py.test Development Team
with same name.
.. _`traceback style docs`: https://pytest.org/latest/usage.html#modifying-python-traceback-printing
.. _`traceback style docs`: https://pytest.org/en/latest/usage.html#modifying-python-traceback-printing
.. _#1422: https://github.com/pytest-dev/pytest/issues/1422
.. _#1379: https://github.com/pytest-dev/pytest/issues/1379

View File

@@ -0,0 +1,20 @@
pytest-4.6.6
=======================================
pytest 4.6.6 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Michael Goerz
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,19 @@
pytest-4.6.7
=======================================
pytest 4.6.7 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Bruno Oliveira
* Daniel Hahler
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,20 @@
pytest-4.6.8
=======================================
pytest 4.6.8 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Ryan Mast
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,21 @@
pytest-4.6.9
=======================================
pytest 4.6.9 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Felix Yan
* Hugo
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,22 @@
pytest-5.2.4
=======================================
pytest 5.2.4 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Hugo
* Michael Shields
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,45 @@
pytest-5.3.0
=======================================
The pytest team is proud to announce the 5.3.0 release!
pytest is a mature Python testing tool with more than a 2000 tests
against itself, passing on many different interpreters and platforms.
This release contains a number of bugs fixes and improvements, so users are encouraged
to take a look at the CHANGELOG:
https://docs.pytest.org/en/latest/changelog.html
For complete documentation, please visit:
https://docs.pytest.org/en/latest/
As usual, you can upgrade from pypi via:
pip install -U pytest
Thanks to all who contributed to this release, among them:
* AnjoMan
* Anthony Sottile
* Anton Lodder
* Bruno Oliveira
* Daniel Hahler
* Gregory Lee
* Josh Karpel
* JoshKarpel
* Joshua Storck
* Kale Kundert
* MarcoGorelli
* Michael Krebs
* NNRepos
* Ran Benita
* TH3CHARLie
* Tibor Arpas
* Zac Hatfield-Dodds
* 林玮
Happy testing,
The Pytest Development Team

View File

@@ -0,0 +1,26 @@
pytest-5.3.1
=======================================
pytest 5.3.1 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Felix Yan
* Florian Bruhin
* Mark Dickinson
* Nikolay Kondratyev
* Steffen Schroeder
* Zac Hatfield-Dodds
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,26 @@
pytest-5.3.2
=======================================
pytest 5.3.2 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Claudio Madotto
* Daniel Hahler
* Jared Vasquez
* Michael Rose
* Ran Benita
* Ronny Pfannschmidt
* Zac Hatfield-Dodds
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,30 @@
pytest-5.3.3
=======================================
pytest 5.3.3 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Adam Johnson
* Alexandre Mulatinho
* Anthony Sottile
* Bruno Oliveira
* Chris NeJame
* Daniel Hahler
* Hugo van Kemenade
* Marcelo Duarte Trevisani
* PaulC
* Ran Benita
* Ryan Barner
* Seth Junot
* marc
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,20 @@
pytest-5.3.4
=======================================
pytest 5.3.4 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Bruno Oliveira
* Daniel Hahler
* Ran Benita
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,19 @@
pytest-5.3.5
=======================================
pytest 5.3.5 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Daniel Hahler
* Ran Benita
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,59 @@
pytest-5.4.0
=======================================
The pytest team is proud to announce the 5.4.0 release!
pytest is a mature Python testing tool with more than a 2000 tests
against itself, passing on many different interpreters and platforms.
This release contains a number of bug fixes and improvements, so users are encouraged
to take a look at the CHANGELOG:
https://docs.pytest.org/en/latest/changelog.html
For complete documentation, please visit:
https://docs.pytest.org/en/latest/
As usual, you can upgrade from PyPI via:
pip install -U pytest
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Christoph Buelter
* Christoph Bülter
* Daniel Arndt
* Daniel Hahler
* Holger Kohr
* Hugo
* Hugo van Kemenade
* Jakub Mitoraj
* Kyle Altendorf
* Minuddin Ahmed Rana
* Nathaniel Compton
* ParetoLife
* Pauli Virtanen
* Philipp Loose
* Ran Benita
* Ronny Pfannschmidt
* Stefan Scherfke
* Stefano Mazzucco
* TWood67
* Tobias Schmidt
* Tomáš Gavenčiak
* Vinay Calastry
* Vladyslav Rachek
* Zac Hatfield-Dodds
* captainCapitalism
* cmachalo
* gftea
* kpinc
* rebecca-palmer
* sdementen
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,18 @@
pytest-5.4.1
=======================================
pytest 5.4.1 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Bruno Oliveira
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,22 @@
pytest-5.4.2
=======================================
pytest 5.4.2 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Ran Benita
* Ronny Pfannschmidt
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,21 @@
pytest-5.4.3
=======================================
pytest 5.4.3 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Ran Benita
* Tor Colvin
Happy testing,
The pytest Development Team

View File

@@ -47,6 +47,8 @@ you will see the return value of the function call:
E + where 3 = f()
test_assert1.py:6: AssertionError
========================= short test summary info ==========================
FAILED test_assert1.py::test_function - assert 3 == 4
============================ 1 failed in 0.12s =============================
``pytest`` has support for showing the values of the most common subexpressions
@@ -208,6 +210,8 @@ if you run this module:
E Use -v to get the full diff
test_assert2.py:6: AssertionError
========================= short test summary info ==========================
FAILED test_assert2.py::test_set_comparison - AssertionError: assert {'0'...
============================ 1 failed in 0.12s =============================
Special comparisons are done for a number of cases:
@@ -279,6 +283,8 @@ the conftest file:
E vals: 1 != 2
test_foocompare.py:12: AssertionError
========================= short test summary info ==========================
FAILED test_foocompare.py::test_compare - assert Comparing Foo instances:
1 failed in 0.12s
.. _assert-details:

View File

@@ -3,6 +3,61 @@
Backwards Compatibility Policy
==============================
.. versionadded: 6.0
pytest is actively evolving and is a project that has been decades in the making,
we keep learning about new and better structures to express different details about testing.
While we implement those modifications we try to ensure an easy transition and don't want to impose unnecessary churn on our users and community/plugin authors.
As of now, pytest considers multipe types of backward compatibility transitions:
a) trivial: APIs which trivially translate to the new mechanism,
and do not cause problematic changes.
We try to support those indefinitely while encouraging users to switch to newer/better mechanisms through documentation.
b) transitional: the old and new API don't conflict
and we can help users transition by using warnings, while supporting both for a prolonged time.
We will only start the removal of deprecated functionality in major releases (e.g. if we deprecate something in 3.0 we will start to remove it in 4.0), and keep it around for at least two minor releases (e.g. if we deprecate something in 3.9 and 4.0 is the next release, we start to remove it in 5.0, not in 4.0).
When the deprecation expires (e.g. 4.0 is released), we won't remove the deprecated functionality immediately, but will use the standard warning filters to turn them into **errors** by default. This approach makes it explicit that removal is imminent, and still gives you time to turn the deprecated feature into a warning instead of an error so it can be dealt with in your own time. In the next minor release (e.g. 4.1), the feature will be effectively removed.
c) true breakage: should only to be considered when normal transition is unreasonably unsustainable and would offset important development/features by years.
In addition, they should be limited to APIs where the number of actual users is very small (for example only impacting some plugins), and can be coordinated with the community in advance.
Examples for such upcoming changes:
* removal of ``pytest_runtest_protocol/nextitem`` - `#895`_
* rearranging of the node tree to include ``FunctionDefinition``
* rearranging of ``SetupState`` `#895`_
True breakages must be announced first in an issue containing:
* Detailed description of the change
* Rationale
* Expected impact on users and plugin authors (example in `#895`_)
After there's no hard *-1* on the issue it should be followed up by an initial proof-of-concept Pull Request.
This POC serves as both a coordination point to assess impact and potential inspriation to come up with a transitional solution after all.
After a reasonable amount of time the PR can be merged to base a new major release.
For the PR to mature from POC to acceptance, it must contain:
* Setup of deprecation errors/warnings that help users fix and port their code. If it is possible to introduce a deprecation period under the current series, before the true breakage, it should be introduced in a separate PR and be part of the current release stream.
* Detailed description of the rationale and examples on how to port code in ``doc/en/deprecations.rst``.
History
=========
Focus primary on smooth transition - stance (pre 6.0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Keeping backwards compatibility has a very high priority in the pytest project. Although we have deprecated functionality over the years, most of it is still supported. All deprecations in pytest were done because simpler or more efficient ways of accomplishing the same tasks have emerged, making the old way of doing things unnecessary.
With the pytest 3.0 release we introduced a clear communication scheme for when we will actually remove the old busted joint and politely ask you to use the new hotness instead, while giving you enough time to adjust your tests or raise concerns if there are valid reasons to keep deprecated functionality around.
@@ -20,3 +75,6 @@ Deprecation Roadmap
Features currently deprecated and removed in previous releases can be found in :ref:`deprecations`.
We track future deprecation and removal of features using milestones and the `deprecation <https://github.com/pytest-dev/pytest/issues?q=label%3A%22type%3A+deprecation%22>`_ and `removal <https://github.com/pytest-dev/pytest/labels/type%3A%20removal>`_ labels on GitHub.
.. _`#895`: https://github.com/pytest-dev/pytest/issues/895

View File

@@ -137,9 +137,11 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
tmpdir_factory [session scope]
Return a :class:`_pytest.tmpdir.TempdirFactory` instance for the test session.
tmp_path_factory [session scope]
Return a :class:`_pytest.tmpdir.TempPathFactory` instance for the test session.
tmpdir
Return a temporary directory path object
which is unique to each test function invocation,

View File

@@ -75,6 +75,9 @@ If you run this for the first time you will see two failures:
E Failed: bad luck
test_50.py:7: Failed
========================= short test summary info ==========================
FAILED test_50.py::test_num[17] - Failed: bad luck
FAILED test_50.py::test_num[25] - Failed: bad luck
2 failed, 48 passed in 0.12s
If you then run it with ``--lf``:
@@ -86,7 +89,7 @@ If you then run it with ``--lf``:
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 50 items / 48 deselected / 2 selected
collected 2 items
run-last-failure: rerun previous 2 failures
test_50.py FF [100%]
@@ -114,7 +117,10 @@ If you then run it with ``--lf``:
E Failed: bad luck
test_50.py:7: Failed
===================== 2 failed, 48 deselected in 0.12s =====================
========================= short test summary info ==========================
FAILED test_50.py::test_num[17] - Failed: bad luck
FAILED test_50.py::test_num[25] - Failed: bad luck
============================ 2 failed in 0.12s =============================
You have run only the two failing tests from the last run, while the 48 passing
tests have not been run ("deselected").
@@ -158,6 +164,9 @@ of ``FF`` and dots):
E Failed: bad luck
test_50.py:7: Failed
========================= short test summary info ==========================
FAILED test_50.py::test_num[17] - Failed: bad luck
FAILED test_50.py::test_num[25] - Failed: bad luck
======================= 2 failed, 48 passed in 0.12s =======================
.. _`config.cache`:
@@ -230,6 +239,8 @@ If you run this command for the first time, you can see the print statement:
test_caching.py:20: AssertionError
-------------------------- Captured stdout setup ---------------------------
running expensive computation...
========================= short test summary info ==========================
FAILED test_caching.py::test_function - assert 42 == 23
1 failed in 0.12s
If you run it a second time, the value will be retrieved from
@@ -249,9 +260,11 @@ the cache and nothing will be printed:
E assert 42 == 23
test_caching.py:20: AssertionError
========================= short test summary info ==========================
FAILED test_caching.py::test_function - assert 42 == 23
1 failed in 0.12s
See the :ref:`cache-api` for more details.
See the :fixture:`config.cache fixture <config.cache>` for more details.
Inspecting Cache content

View File

@@ -21,27 +21,36 @@ file descriptors. This allows to capture output from simple
print statements as well as output from a subprocess started by
a test.
.. _capture-method:
Setting capturing methods or disabling capturing
-------------------------------------------------
There are two ways in which ``pytest`` can perform capturing:
There are three ways in which ``pytest`` can perform capturing:
* file descriptor (FD) level capturing (default): All writes going to the
* ``fd`` (file descriptor) level capturing (default): All writes going to the
operating system file descriptors 1 and 2 will be captured.
* ``sys`` level capturing: Only writes to Python files ``sys.stdout``
and ``sys.stderr`` will be captured. No capturing of writes to
filedescriptors is performed.
* ``tee-sys`` capturing: Python writes to ``sys.stdout`` and ``sys.stderr``
will be captured, however the writes will also be passed-through to
the actual ``sys.stdout`` and ``sys.stderr``. This allows output to be
'live printed' and captured for plugin use, such as junitxml (new in pytest 5.4).
.. _`disable capturing`:
You can influence output capturing mechanisms from the command line:
.. code-block:: bash
pytest -s # disable all capturing
pytest --capture=sys # replace sys.stdout/stderr with in-mem files
pytest --capture=fd # also point filedescriptors 1 and 2 to temp file
pytest -s # disable all capturing
pytest --capture=sys # replace sys.stdout/stderr with in-mem files
pytest --capture=fd # also point filedescriptors 1 and 2 to temp file
pytest --capture=tee-sys # combines 'sys' and '-s', capturing sys.stdout/stderr
# and passing it along to the actual sys.stdout/stderr
.. _printdebugging:
@@ -91,6 +100,8 @@ of the failing function and hide the other one:
test_module.py:12: AssertionError
-------------------------- Captured stdout setup ---------------------------
setting up <function test_func2 at 0xdeadbeef>
========================= short test summary info ==========================
FAILED test_module.py::test_func2 - assert False
======================= 1 failed, 1 passed in 0.12s ========================
Accessing captured output from a test function
@@ -159,5 +170,3 @@ as a context manager, disabling capture inside the ``with`` block:
with capsys.disabled():
print("output not captured, going directly to sys.stdout")
print("this output is also captured")
.. include:: links.inc

File diff suppressed because it is too large Load Diff

View File

@@ -19,6 +19,11 @@ import os
import sys
from _pytest import __version__ as version
from _pytest.compat import TYPE_CHECKING
if TYPE_CHECKING:
import sphinx.application
release = ".".join(version.split(".")[:2])
@@ -62,7 +67,7 @@ master_doc = "contents"
# General information about the project.
project = "pytest"
copyright = "20152019, holger krekel and pytest-dev team"
copyright = "20152020, holger krekel and pytest-dev team"
# The language for content autogenerated by Sphinx. Refer to documentation
@@ -78,7 +83,6 @@ copyright = "20152019, holger krekel and pytest-dev team"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = [
"links.inc",
"_build",
"naming20.rst",
"test/*",
@@ -92,7 +96,7 @@ exclude_patterns = [
# The reST default role (used for this markup: `text`) to use for all documents.
# default_role = None
default_role = "literal"
# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True
@@ -112,6 +116,19 @@ pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
# A list of regular expressions that match URIs that should not be checked when
# doing a linkcheck.
linkcheck_ignore = [
"https://github.com/numpy/numpy/blob/master/doc/release/1.16.0-notes.rst#new-deprecations",
"https://blogs.msdn.microsoft.com/bharry/2017/06/28/testing-in-a-cloud-delivery-cadence/",
"http://pythontesting.net/framework/pytest-introduction/",
r"https://github.com/pytest-dev/pytest/issues/\d+",
r"https://github.com/pytest-dev/pytest/pull/\d+",
]
# The number of worker threads to use when checking links (default=5).
linkcheck_workers = 5
# -- Options for HTML output ---------------------------------------------------
@@ -144,7 +161,7 @@ html_logo = "img/pytest1.png"
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = "img/pytest1favi.ico"
html_favicon = "img/favicon.png"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
@@ -190,7 +207,7 @@ html_sidebars = {
html_domain_indices = True
# If false, no index is generated.
html_use_index = False
html_use_index = True
# If true, the index is split into individual pages for each letter.
# html_split_index = False
@@ -272,7 +289,7 @@ man_pages = [("usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"
epub_title = "pytest"
epub_author = "holger krekel at merlinux eu"
epub_publisher = "holger krekel at merlinux eu"
epub_copyright = "2013, holger krekel et alii"
epub_copyright = "2013-2020, holger krekel et alii"
# The language of the text. It defaults to the language option
# or en if the language is not set.
@@ -329,12 +346,44 @@ texinfo_documents = [
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
def setup(app):
def configure_logging(app: "sphinx.application.Sphinx") -> None:
"""Configure Sphinx's WarningHandler to handle (expected) missing include."""
import sphinx.util.logging
import logging
class WarnLogFilter(logging.Filter):
def filter(self, record: logging.LogRecord) -> bool:
"""Ignore warnings about missing include with "only" directive.
Ref: https://github.com/sphinx-doc/sphinx/issues/2150."""
if (
record.msg.startswith('Problems with "include" directive path:')
and "_changelog_towncrier_draft.rst" in record.msg
):
return False
return True
logger = logging.getLogger(sphinx.util.logging.NAMESPACE)
warn_handler = [x for x in logger.handlers if x.level == logging.WARNING]
assert len(warn_handler) == 1, warn_handler
warn_handler[0].filters.insert(0, WarnLogFilter())
def setup(app: "sphinx.application.Sphinx") -> None:
# from sphinx.ext.autodoc import cut_lines
# app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
app.add_crossref_type(
"fixture",
"fixture",
objname="built-in fixture",
indextemplate="pair: %s; fixture",
)
app.add_object_type(
"confval",
"confval",
objname="configuration value",
indextemplate="pair: %s; configuration value",
)
configure_logging(app)

View File

@@ -20,8 +20,6 @@ which were registered by installed plugins.
Initialization: determining rootdir and inifile
-----------------------------------------------
pytest determines a ``rootdir`` for each test run which depends on
the command line arguments (specified test files, paths) and on
the existence of *ini-files*. The determined ``rootdir`` and *ini-file* are
@@ -30,17 +28,17 @@ printed as part of the pytest header during startup.
Here's a summary what ``pytest`` uses ``rootdir`` for:
* Construct *nodeids* during collection; each test is assigned
a unique *nodeid* which is rooted at the ``rootdir`` and takes in account full path,
class name, function name and parametrization (if any).
a unique *nodeid* which is rooted at the ``rootdir`` and takes into account
the full path, class name, function name and parametrization (if any).
* Is used by plugins as a stable location to store project/test run specific information;
for example, the internal :ref:`cache <cache>` plugin creates a ``.pytest_cache`` subdirectory
in ``rootdir`` to store its cross-test run state.
Important to emphasize that ``rootdir`` is **NOT** used to modify ``sys.path``/``PYTHONPATH`` or
``rootdir`` is **NOT** used to modify ``sys.path``/``PYTHONPATH`` or
influence how modules are imported. See :ref:`pythonpath` for more details.
``--rootdir=path`` command-line option can be used to force a specific directory.
The ``--rootdir=path`` command-line option can be used to force a specific directory.
The directory passed may contain environment variables when it is used in conjunction
with ``addopts`` in a ``pytest.ini`` file.

View File

@@ -20,6 +20,51 @@ Below is a complete list of all pytest features which are considered deprecated.
:ref:`standard warning filters <warnings>`.
``--no-print-logs`` command-line option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 5.4
Option ``--no-print-logs`` is deprecated and meant to be removed in a future release. If you use ``--no-print-logs``, please try out ``--show-capture`` and
provide feedback.
``--show-capture`` command-line option was added in ``pytest 3.5.0` and allows to specify how to
display captured output when tests fail: ``no``, ``stdout``, ``stderr``, ``log`` or ``all`` (the default).
Node Construction changed to ``Node.from_parent``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 5.4
The construction of nodes new should use the named constructor ``from_parent``.
This limitation in api surface intends to enable better/simpler refactoring of the collection tree.
``junit_family`` default value change to "xunit2"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 5.2
The default value of ``junit_family`` option will change to ``xunit2`` in pytest 6.0, given
that this is the version supported by default in modern tools that manipulate this type of file.
In order to smooth the transition, pytest will issue a warning in case the ``--junitxml`` option
is given in the command line but ``junit_family`` is not explicitly configured in ``pytest.ini``::
PytestDeprecationWarning: The 'junit_family' default value will change to 'xunit2' in pytest 6.0.
Add 'junit_family=legacy' to your pytest.ini file to silence this warning and make your suite compatible.
In order to silence this warning, users just need to configure the ``junit_family`` option explicitly:
.. code-block:: ini
[pytest]
junit_family=legacy
``funcargnames`` alias for ``fixturenames``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -40,15 +85,27 @@ Result log (``--result-log``)
.. deprecated:: 4.0
The ``--result-log`` option produces a stream of test reports which can be
analysed at runtime. It uses a custom format which requires users to implement their own
parser, but the team believes using a line-based format that can be parsed using standard
tools would provide a suitable and better alternative.
analysed at runtime, but it uses a custom format which requires users to implement their own
parser.
The current plan is to provide an alternative in the pytest 5.0 series and remove the ``--result-log``
option in pytest 6.0 after the new implementation proves satisfactory to all users and is deemed
stable.
The `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__ plugin provides a ``--report-log`` option, a more standard and extensible alternative, producing
one JSON object per-line, and should cover the same use cases. Please try it out and provide feedback.
The actual alternative is still being discussed in issue `#4488 <https://github.com/pytest-dev/pytest/issues/4488>`__.
The plan is remove the ``--result-log`` option in pytest 6.0 if ``pytest-reportlog`` proves satisfactory
to all users and is deemed stable. The ``pytest-reportlog`` plugin might even be merged into the core
at some point, depending on the plans for the plugins and number of users using it.
TerminalReporter.writer
~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 5.4
The ``TerminalReporter.writer`` attribute has been deprecated and should no longer be used. This
was inadvertently exposed as part of the public API of that plugin and ties it too much
with ``py.io.TerminalWriter``.
Plugins that used ``TerminalReporter.writer`` directly should instead use ``TerminalReporter``
methods that provide the same functionality.
Removed Features

View File

@@ -19,7 +19,7 @@ Branches
We have two long term branches:
* ``master``: contains the code for the next bugfix release.
* ``master``: contains the code for the next bug-fix release.
* ``features``: contains the code with new features for the next minor release.
The official repository usually does not contain topic branches, developers and contributors should create topic
@@ -57,4 +57,4 @@ Issues created at those events should have other relevant labels added as well.
Those labels should be removed after they are no longer relevant.
.. include:: ../../HOWTORELEASE.rst
.. include:: ../../RELEASING.rst

View File

@@ -1,20 +0,0 @@
import pytest
@pytest.fixture(scope="session")
def setup(request):
setup = CostlySetup()
yield setup
setup.finalize()
class CostlySetup:
def __init__(self):
import time
print("performing costly setup")
time.sleep(5)
self.timecostly = 1
def finalize(self):
del self.timecostly

View File

@@ -1 +0,0 @@
#

View File

@@ -1,2 +0,0 @@
def test_quick(setup):
pass

View File

@@ -1 +0,0 @@
#

View File

@@ -1,6 +0,0 @@
def test_something(setup):
assert setup.timecostly == 1
def test_something_more(setup):
assert setup.timecostly == 1

View File

@@ -148,6 +148,10 @@ which implements a substring match on the test names instead of the
exact match on markers that ``-m`` provides. This makes it easy to
select tests based on their names:
.. versionadded: 5.4
The expression matching is now case-insensitive.
.. code-block:: pytest
$ pytest -v -k http # running with the above defined example module
@@ -622,7 +626,7 @@ then you will see two tests skipped and two executed tests as expected:
test_plat.py s.s. [100%]
========================= short test summary info ==========================
SKIPPED [2] $REGENDOC_TMPDIR/conftest.py:13: cannot run on platform linux
SKIPPED [2] $REGENDOC_TMPDIR/conftest.py:12: cannot run on platform linux
======================= 2 passed, 2 skipped in 0.12s =======================
Note that if you specify a platform via the marker-command line option like this:
@@ -711,6 +715,9 @@ We can now use the ``-m option`` to select one set:
test_module.py:8: in test_interface_complex
assert 0
E assert 0
========================= short test summary info ==========================
FAILED test_module.py::test_interface_simple - assert 0
FAILED test_module.py::test_interface_complex - assert 0
===================== 2 failed, 2 deselected in 0.12s ======================
or to select both "event" and "interface" tests:
@@ -739,4 +746,8 @@ or to select both "event" and "interface" tests:
test_module.py:12: in test_event_simple
assert 0
E assert 0
========================= short test summary info ==========================
FAILED test_module.py::test_interface_simple - assert 0
FAILED test_module.py::test_interface_complex - assert 0
FAILED test_module.py::test_event_simple - assert 0
===================== 3 failed, 1 deselected in 0.12s ======================

View File

@@ -41,6 +41,8 @@ now execute the test specification:
usecase execution failed
spec failed: 'some': 'other'
no further details known at this point.
========================= short test summary info ==========================
FAILED test_simple.yaml::hello
======================= 1 failed, 1 passed in 0.12s ========================
.. regendoc:wipe
@@ -77,6 +79,8 @@ consulted when reporting in ``verbose`` mode:
usecase execution failed
spec failed: 'some': 'other'
no further details known at this point.
========================= short test summary info ==========================
FAILED test_simple.yaml::hello
======================= 1 failed, 1 passed in 0.12s ========================
.. regendoc:wipe

View File

@@ -4,7 +4,7 @@ import pytest
def pytest_collect_file(parent, path):
if path.ext == ".yaml" and path.basename.startswith("test"):
return YamlFile(path, parent)
return YamlFile.from_parent(parent, fspath=path)
class YamlFile(pytest.File):
@@ -13,7 +13,7 @@ class YamlFile(pytest.File):
raw = yaml.safe_load(self.fspath.open())
for name, spec in sorted(raw.items()):
yield YamlItem(name, self, spec)
yield YamlItem.from_parent(self, name=name, spec=spec)
class YamlItem(pytest.Item):

View File

@@ -73,6 +73,8 @@ let's run the full monty:
E assert 4 < 4
test_compute.py:4: AssertionError
========================= short test summary info ==========================
FAILED test_compute.py::test_compute[4] - assert 4 < 4
1 failed, 4 passed in 0.12s
As expected when running the full range of ``param1`` values
@@ -343,6 +345,8 @@ And then when we run the test:
E Failed: deliberately failing for demo purposes
test_backends.py:8: Failed
========================= short test summary info ==========================
FAILED test_backends.py::test_db_initialized[d2] - Failed: deliberately f...
1 failed, 1 passed in 0.12s
The first invocation with ``db == "DB1"`` passed while the second with ``db == "DB2"`` failed. Our ``db`` fixture function has instantiated each of the DB values during the setup phase while the ``pytest_generate_tests`` generated two according calls to the ``test_db_initialized`` during the collection phase.
@@ -454,6 +458,8 @@ argument sets to use for each test function. Let's run it:
E assert 1 == 2
test_parametrize.py:21: AssertionError
========================= short test summary info ==========================
FAILED test_parametrize.py::TestClass::test_equals[1-2] - assert 1 == 2
1 failed, 2 passed in 0.12s
Indirect parametrization with multiple fixtures
@@ -475,11 +481,10 @@ Running it results in some skips if we don't have all the python interpreters in
.. code-block:: pytest
. $ pytest -rs -q multipython.py
ssssssssssss...ssssssssssss [100%]
ssssssssssss......sss...... [100%]
========================= short test summary info ==========================
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.7' not found
3 passed, 24 skipped in 0.12s
SKIPPED [15] $REGENDOC_TMPDIR/CWD/multipython.py:29: 'python3.5' not found
12 passed, 15 skipped in 0.12s
Indirect parametrization of optional implementations/imports
--------------------------------------------------------------------
@@ -547,7 +552,7 @@ If you run this with reporting for skips enabled:
test_module.py .s [100%]
========================= short test summary info ==========================
SKIPPED [1] $REGENDOC_TMPDIR/conftest.py:13: could not import 'opt2': No module named 'opt2'
SKIPPED [1] $REGENDOC_TMPDIR/conftest.py:12: could not import 'opt2': No module named 'opt2'
======================= 1 passed, 1 skipped in 0.12s =======================
You'll see that we don't have an ``opt2`` module and thus the second test run
@@ -604,13 +609,13 @@ Then run ``pytest`` with verbose mode and with only the ``basic`` marker:
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collecting ... collected 18 items / 15 deselected / 3 selected
collecting ... collected 14 items / 11 deselected / 3 selected
test_pytest_param_example.py::test_eval[1+7-8] PASSED [ 33%]
test_pytest_param_example.py::test_eval[basic_2+4] PASSED [ 66%]
test_pytest_param_example.py::test_eval[basic_6*9] XFAIL [100%]
=============== 2 passed, 15 deselected, 1 xfailed in 0.12s ================
=============== 2 passed, 11 deselected, 1 xfailed in 0.12s ================
As the result:

View File

@@ -1,16 +0,0 @@
import sys
import pytest
py3 = sys.version_info[0] >= 3
class DummyCollector(pytest.collect.File):
def collect(self):
return []
def pytest_pycollect_makemodule(path, parent):
bn = path.basename
if "py3" in bn and not py3 or ("py2" in bn and py3):
return DummyCollector(path, parent=parent)

View File

@@ -1,5 +0,0 @@
def test_exception_syntax():
try:
0 / 0
except ZeroDivisionError, e:
assert e

View File

@@ -1,5 +0,0 @@
def test_exception_syntax():
try:
0 / 0
except ZeroDivisionError as e:
assert e

View File

@@ -81,8 +81,8 @@ Here is a nice run of several failures and how ``pytest`` presents things:
def test_eq_text(self):
> assert "spam" == "eggs"
E AssertionError: assert 'spam' == 'eggs'
E - spam
E + eggs
E - eggs
E + spam
failure_demo.py:45: AssertionError
_____________ TestSpecialisedExplanations.test_eq_similar_text _____________
@@ -92,9 +92,9 @@ Here is a nice run of several failures and how ``pytest`` presents things:
def test_eq_similar_text(self):
> assert "foo 1 bar" == "foo 2 bar"
E AssertionError: assert 'foo 1 bar' == 'foo 2 bar'
E - foo 1 bar
E - foo 2 bar
E ? ^
E + foo 2 bar
E + foo 1 bar
E ? ^
failure_demo.py:48: AssertionError
@@ -106,8 +106,8 @@ Here is a nice run of several failures and how ``pytest`` presents things:
> assert "foo\nspam\nbar" == "foo\neggs\nbar"
E AssertionError: assert 'foo\nspam\nbar' == 'foo\neggs\nbar'
E foo
E - spam
E + eggs
E - eggs
E + spam
E bar
failure_demo.py:51: AssertionError
@@ -122,9 +122,9 @@ Here is a nice run of several failures and how ``pytest`` presents things:
E AssertionError: assert '111111111111...2222222222222' == '111111111111...2222222222222'
E Skipping 90 identical leading characters in diff, use -v to show
E Skipping 91 identical trailing characters in diff, use -v to show
E - 1111111111a222222222
E - 1111111111b222222222
E ? ^
E + 1111111111b222222222
E + 1111111111a222222222
E ? ^
failure_demo.py:56: AssertionError
@@ -436,7 +436,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
items = [1, 2, 3]
print("items is {!r}".format(items))
> a, b = items.pop()
E TypeError: 'int' object is not iterable
E TypeError: cannot unpack non-iterable int object
failure_demo.py:181: TypeError
--------------------------- Captured stdout call ---------------------------
@@ -516,7 +516,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
def test_z2_type_error(self):
items = 3
> a, b = items
E TypeError: 'int' object is not iterable
E TypeError: cannot unpack non-iterable int object
failure_demo.py:222: TypeError
______________________ TestMoreErrors.test_startswith ______________________
@@ -650,4 +650,49 @@ Here is a nice run of several failures and how ``pytest`` presents things:
E + where 1 = This is JSON\n{\n 'foo': 'bar'\n}.a
failure_demo.py:282: AssertionError
========================= short test summary info ==========================
FAILED failure_demo.py::test_generative[3-6] - assert (3 * 2) < 6
FAILED failure_demo.py::TestFailing::test_simple - assert 42 == 43
FAILED failure_demo.py::TestFailing::test_simple_multiline - assert 42 == 54
FAILED failure_demo.py::TestFailing::test_not - assert not 42
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_text - Asser...
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_similar_text
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_multiline_text
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_long_text - ...
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_long_text_multiline
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_list - asser...
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_list_long - ...
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_dict - Asser...
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_set - Assert...
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_longer_list
FAILED failure_demo.py::TestSpecialisedExplanations::test_in_list - asser...
FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_multiline
FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_single
FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_single_long
FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_single_long_term
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_dataclass - ...
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_attrs - Asse...
FAILED failure_demo.py::test_attribute - assert 1 == 2
FAILED failure_demo.py::test_attribute_instance - AssertionError: assert ...
FAILED failure_demo.py::test_attribute_failure - Exception: Failed to get...
FAILED failure_demo.py::test_attribute_multiple - AssertionError: assert ...
FAILED failure_demo.py::TestRaises::test_raises - ValueError: invalid lit...
FAILED failure_demo.py::TestRaises::test_raises_doesnt - Failed: DID NOT ...
FAILED failure_demo.py::TestRaises::test_raise - ValueError: demo error
FAILED failure_demo.py::TestRaises::test_tupleerror - ValueError: not eno...
FAILED failure_demo.py::TestRaises::test_reinterpret_fails_with_print_for_the_fun_of_it
FAILED failure_demo.py::TestRaises::test_some_error - NameError: name 'na...
FAILED failure_demo.py::test_dynamic_compile_shows_nicely - AssertionError
FAILED failure_demo.py::TestMoreErrors::test_complex_error - assert 44 == 43
FAILED failure_demo.py::TestMoreErrors::test_z1_unpack_error - ValueError...
FAILED failure_demo.py::TestMoreErrors::test_z2_type_error - TypeError: c...
FAILED failure_demo.py::TestMoreErrors::test_startswith - AssertionError:...
FAILED failure_demo.py::TestMoreErrors::test_startswith_nested - Assertio...
FAILED failure_demo.py::TestMoreErrors::test_global_func - assert False
FAILED failure_demo.py::TestMoreErrors::test_instance - assert 42 != 42
FAILED failure_demo.py::TestMoreErrors::test_compare - assert 11 < 5
FAILED failure_demo.py::TestMoreErrors::test_try_finally - assert 1 == 0
FAILED failure_demo.py::TestCustomAssertMsg::test_single_line - Assertion...
FAILED failure_demo.py::TestCustomAssertMsg::test_multiline - AssertionEr...
FAILED failure_demo.py::TestCustomAssertMsg::test_custom_repr - Assertion...
============================ 44 failed in 0.12s ============================

View File

@@ -65,6 +65,8 @@ Let's run this without supplying our new option:
test_sample.py:6: AssertionError
--------------------------- Captured stdout call ---------------------------
first
========================= short test summary info ==========================
FAILED test_sample.py::test_answer - assert 0
1 failed in 0.12s
And now with supplying a command line option:
@@ -89,6 +91,8 @@ And now with supplying a command line option:
test_sample.py:6: AssertionError
--------------------------- Captured stdout call ---------------------------
second
========================= short test summary info ==========================
FAILED test_sample.py::test_answer - assert 0
1 failed in 0.12s
You can see that the command line option arrived in our test. This
@@ -261,6 +265,8 @@ Let's run our little function:
E Failed: not configured: 42
test_checkconfig.py:11: Failed
========================= short test summary info ==========================
FAILED test_checkconfig.py::test_something - Failed: not configured: 42
1 failed in 0.12s
If you only want to hide certain exceptions, you can set ``__tracebackhide__``
@@ -300,36 +306,33 @@ behave differently if called from a test. But if you
absolutely must find out if your application code is
running from a test you can do something like this:
.. code-block:: python
# content of your_module.py
_called_from_test = False
.. code-block:: python
# content of conftest.py
def pytest_configure(config):
import sys
your_module._called_from_test = True
sys._called_from_test = True
def pytest_unconfigure(config):
import sys
del sys._called_from_test
and then check for the ``sys._called_from_test`` flag:
and then check for the ``your_module._called_from_test`` flag:
.. code-block:: python
if hasattr(sys, "_called_from_test"):
if your_module._called_from_test:
# called from within a test run
...
else:
# called "normally"
...
accordingly in your application. It's also a good idea
to use your own application module rather than ``sys``
for handling flag.
accordingly in your application.
Adding info to test report header
--------------------------------------------------------------
@@ -464,21 +467,52 @@ an ``incremental`` marker which is to be used on classes:
# content of conftest.py
from typing import Dict, Tuple
import pytest
# store history of failures per test class name and per index in parametrize (if parametrize used)
_test_failed_incremental: Dict[str, Dict[Tuple[int, ...], str]] = {}
def pytest_runtest_makereport(item, call):
if "incremental" in item.keywords:
# incremental marker is used
if call.excinfo is not None:
parent = item.parent
parent._previousfailed = item
# the test has failed
# retrieve the class name of the test
cls_name = str(item.cls)
# retrieve the index of the test (if parametrize is used in combination with incremental)
parametrize_index = (
tuple(item.callspec.indices.values())
if hasattr(item, "callspec")
else ()
)
# retrieve the name of the test function
test_name = item.originalname or item.name
# store in _test_failed_incremental the original name of the failed test
_test_failed_incremental.setdefault(cls_name, {}).setdefault(
parametrize_index, test_name
)
def pytest_runtest_setup(item):
if "incremental" in item.keywords:
previousfailed = getattr(item.parent, "_previousfailed", None)
if previousfailed is not None:
pytest.xfail("previous test failed ({})".format(previousfailed.name))
# retrieve the class name of the test
cls_name = str(item.cls)
# check if a previous test has failed for this class
if cls_name in _test_failed_incremental:
# retrieve the index of the test (if parametrize is used in combination with incremental)
parametrize_index = (
tuple(item.callspec.indices.values())
if hasattr(item, "callspec")
else ()
)
# retrieve the name of the first test function to fail for this class name and index
test_name = _test_failed_incremental[cls_name].get(parametrize_index, None)
# if name found, test has failed for the combination of class name & test name
if test_name is not None:
pytest.xfail("previous test failed ({})".format(test_name))
These two hook implementations work together to abort incremental-marked
tests in a class. Here is a test module example:
@@ -644,6 +678,11 @@ We can run this:
E assert 0
a/test_db2.py:2: AssertionError
========================= short test summary info ==========================
FAILED test_step.py::TestUserHandling::test_modification - assert 0
FAILED a/test_db.py::test_a1 - AssertionError: <conftest.DB object at 0x7...
FAILED a/test_db2.py::test_a2 - AssertionError: <conftest.DB object at 0x...
ERROR b/test_error.py::test_root
============= 3 failed, 2 passed, 1 xfailed, 1 error in 0.12s ==============
The two test modules in the ``a`` directory see the same ``db`` fixture instance
@@ -733,6 +772,9 @@ and run them:
E assert 0
test_module.py:6: AssertionError
========================= short test summary info ==========================
FAILED test_module.py::test_fail1 - assert 0
FAILED test_module.py::test_fail2 - assert 0
============================ 2 failed in 0.12s =============================
you will have a "failures" file which contains the failing test ids:
@@ -848,6 +890,10 @@ and run it:
E assert 0
test_module.py:19: AssertionError
========================= short test summary info ==========================
FAILED test_module.py::test_call_fails - assert 0
FAILED test_module.py::test_fail2 - assert 0
ERROR test_module.py::test_setup_fails - assert 0
======================== 2 failed, 1 error in 0.12s ========================
You'll see that the fixture finalizers could use the precise reporting

View File

@@ -32,5 +32,3 @@ reinstall every time you want to run your tests, and is less brittle than
mucking about with sys.path to point your tests at local code.
Also consider using :ref:`tox <use tox>`.
.. include:: links.inc

View File

@@ -153,4 +153,6 @@ As of mid-2013, there shouldn't be a problem anymore when you
use the standard setuptools (note that distribute has been merged
back into setuptools which is now shipped directly with virtualenv).
.. include:: links.inc
.. _nose: https://nose.readthedocs.io/en/latest/
.. _pylib: https://py.readthedocs.io/en/latest/
.. _`xUnit style setup`: xunit_setup.html

View File

@@ -9,14 +9,20 @@ pytest fixtures: explicit, modular, scalable
.. _`xUnit`: http://en.wikipedia.org/wiki/XUnit
.. _`purpose of test fixtures`: http://en.wikipedia.org/wiki/Test_fixture#Software
.. _`Dependency injection`: http://en.wikipedia.org/wiki/Dependency_injection
.. _`xUnit`: https://en.wikipedia.org/wiki/XUnit
.. _`Software test fixtures`: https://en.wikipedia.org/wiki/Test_fixture#Software
.. _`Dependency injection`: https://en.wikipedia.org/wiki/Dependency_injection
The `purpose of test fixtures`_ is to provide a fixed baseline
upon which tests can reliably and repeatedly execute. pytest fixtures
offer dramatic improvements over the classic xUnit style of setup/teardown
functions:
`Software test fixtures`_ initialize test functions. They provide a
fixed baseline so that tests execute reliably and produce consistent,
repeatable, results. Initialization may setup services, state, or
other operating environments. These are accessed by test functions
through arguments; for each fixture used by a test function there is
typically a parameter (named after the fixture) in the test function's
definition.
pytest fixtures offer dramatic improvements over the classic xUnit
style of setup/teardown functions:
* fixtures have explicit names and are activated by declaring their use
from test functions, modules, classes or whole projects.
@@ -34,6 +40,74 @@ both styles, moving incrementally from classic to new style, as you
prefer. You can also start out from existing :ref:`unittest.TestCase
style <unittest.TestCase>` or :ref:`nose based <nosestyle>` projects.
:ref:`Fixtures <fixtures-api>` are defined using the
:ref:`@pytest.fixture <pytest.fixture-api>` decorator, :ref:`described
below <funcargs>`. Pytest has useful built-in fixtures, listed here
for reference:
:fixture:`capfd`
Capture, as text, output to file descriptors ``1`` and ``2``.
:fixture:`capfdbinary`
Capture, as bytes, output to file descriptors ``1`` and ``2``.
:fixture:`caplog`
Control logging and access log entries.
:fixture:`capsys`
Capture, as text, output to ``sys.stdout`` and ``sys.stderr``.
:fixture:`capsysbinary`
Capture, as bytes, output to ``sys.stdout`` and ``sys.stderr``.
:fixture:`cache`
Store and retrieve values across pytest runs.
:fixture:`doctest_namespace`
Provide a dict injected into the docstests namespace.
:fixture:`monkeypatch`
Temporarily modify classes, functions, dictionaries,
``os.environ``, and other objects.
:fixture:`pytestconfig`
Access to configuration values, pluginmanager and plugin hooks.
:fixture:`record_property`
Add extra properties to the test.
:fixture:`record_testsuite_property`
Add extra properties to the test suite.
:fixture:`recwarn`
Record warnings emitted by test functions.
:fixture:`request`
Provide information on the executing test function.
:fixture:`testdir`
Provide a temporary test directory to aid in running, and
testing, pytest plugins.
:fixture:`tmp_path`
Provide a :class:`pathlib.Path` object to a temporary directory
which is unique to each test function.
:fixture:`tmp_path_factory`
Make session-scoped temporary directories and return
:class:`pathlib.Path` objects.
:fixture:`tmpdir`
Provide a :class:`py.path.local` object to a temporary
directory which is unique to each test function;
replaced by :fixture:`tmp_path`.
.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
:fixture:`tmpdir_factory`
Make session-scoped temporary directories and return
:class:`py.path.local` objects;
replaced by :fixture:`tmp_path_factory`.
.. _`funcargs`:
.. _`funcarg mechanism`:
@@ -96,6 +170,8 @@ marked ``smtp_connection`` fixture function. Running the test looks like this:
E assert 0
test_smtpsimple.py:14: AssertionError
========================= short test summary info ==========================
FAILED test_smtpsimple.py::test_ehlo - assert 0
============================ 1 failed in 0.12s =============================
In the failure traceback we see that the test function was called with a
@@ -258,6 +334,9 @@ inspect what is going on and can now run the tests:
E assert 0
test_module.py:13: AssertionError
========================= short test summary info ==========================
FAILED test_module.py::test_ehlo - assert 0
FAILED test_module.py::test_noop - assert 0
============================ 2 failed in 0.12s =============================
You see the two ``assert 0`` failing and more importantly you can also see
@@ -320,7 +399,7 @@ containers for different environments. See the example below.
.. code-block:: python
def determine_scope(fixture_name, config):
if config.getoption("--keep-containers"):
if config.getoption("--keep-containers", None):
return "session"
return "function"
@@ -391,6 +470,9 @@ Let's execute it:
$ pytest -s -q --tb=no
FFteardown smtp
========================= short test summary info ==========================
FAILED test_module.py::test_ehlo - assert 0
FAILED test_module.py::test_noop - assert 0
2 failed in 0.12s
We see that the ``smtp_connection`` instance is finalized after the two
@@ -545,6 +627,9 @@ again, nothing much has changed:
$ pytest -s -q --tb=no
FFfinalizing <smtplib.SMTP object at 0xdeadbeef> (smtp.gmail.com)
========================= short test summary info ==========================
FAILED test_module.py::test_ehlo - assert 0
FAILED test_module.py::test_noop - assert 0
2 failed in 0.12s
Let's quickly create another test module that actually sets the
@@ -574,6 +659,8 @@ Running it:
E assert 0
------------------------- Captured stdout teardown -------------------------
finalizing <smtplib.SMTP object at 0xdeadbeef> (mail.python.org)
========================= short test summary info ==========================
FAILED test_anothersmtp.py::test_showhelo - AssertionError: (250, b'mail....
voila! The ``smtp_connection`` fixture function picked up our mail server name
from the module namespace.
@@ -722,6 +809,11 @@ So let's just do another run:
test_module.py:13: AssertionError
------------------------- Captured stdout teardown -------------------------
finalizing <smtplib.SMTP object at 0xdeadbeef>
========================= short test summary info ==========================
FAILED test_module.py::test_ehlo[smtp.gmail.com] - assert 0
FAILED test_module.py::test_noop[smtp.gmail.com] - assert 0
FAILED test_module.py::test_ehlo[mail.python.org] - AssertionError: asser...
FAILED test_module.py::test_noop[mail.python.org] - assert 0
4 failed in 0.12s
We see that our two test functions each ran twice, against the different
@@ -849,7 +941,7 @@ Running this test will *skip* the invocation of ``data_set`` with value ``2``:
Modularity: using fixtures from a fixture function
----------------------------------------------------------
You can not only use fixtures in test functions but fixture functions
In addition to using fixtures in test functions, fixture functions
can use other fixtures themselves. This contributes to a modular design
of your fixtures and allows re-use of framework-specific fixtures across
many projects. As a simple example, we can extend the previous example
@@ -1035,15 +1127,21 @@ file:
# content of conftest.py
import pytest
import tempfile
import os
import shutil
import tempfile
import pytest
@pytest.fixture()
@pytest.fixture
def cleandir():
old_cwd = os.getcwd()
newpath = tempfile.mkdtemp()
os.chdir(newpath)
yield
os.chdir(old_cwd)
shutil.rmtree(newpath)
and declare its use in a test module via a ``usefixtures`` marker:

View File

@@ -28,7 +28,7 @@ Install ``pytest``
.. code-block:: bash
$ pytest --version
This is pytest version 5.x.y, imported from $PYTHON_PREFIX/lib/python3.6/site-packages/pytest.py
This is pytest version 5.x.y, imported from $PYTHON_PREFIX/lib/python3.8/site-packages/pytest/__init__.py
.. _`simpletest`:
@@ -69,6 +69,8 @@ Thats it. You can now execute the test function:
E + where 4 = func(3)
test_sample.py:6: AssertionError
========================= short test summary info ==========================
FAILED test_sample.py::test_answer - assert 4 == 5
============================ 1 failed in 0.12s =============================
This test returns a failure report because ``func(3)`` does not return ``5``.
@@ -127,7 +129,7 @@ Once you develop multiple tests, you may want to group them into a class. pytest
x = "hello"
assert hasattr(x, "check")
``pytest`` discovers all tests following its :ref:`Conventions for Python test discovery <test discovery>`, so it finds both ``test_`` prefixed functions. There is no need to subclass anything. We can simply run the module by passing its filename:
``pytest`` discovers all tests following its :ref:`Conventions for Python test discovery <test discovery>`, so it finds both ``test_`` prefixed functions. There is no need to subclass anything, but make sure to prefix your class with ``Test`` otherwise the class will be skipped. We can simply run the module by passing its filename:
.. code-block:: pytest
@@ -145,6 +147,8 @@ Once you develop multiple tests, you may want to group them into a class. pytest
E + where False = hasattr('hello', 'check')
test_class.py:8: AssertionError
========================= short test summary info ==========================
FAILED test_class.py::TestClass::test_two - AssertionError: assert False
1 failed, 1 passed in 0.12s
The first test passed and the second failed. You can easily see the intermediate values in the assertion to help you understand the reason for the failure.
@@ -180,6 +184,8 @@ List the name ``tmpdir`` in the test function signature and ``pytest`` will look
test_tmpdir.py:3: AssertionError
--------------------------- Captured stdout call ---------------------------
PYTEST_TMPDIR/test_needsfiles0
========================= short test summary info ==========================
FAILED test_tmpdir.py::test_needsfiles - assert 0
1 failed in 0.12s
More info on tmpdir handling is available at :ref:`Temporary directories and files <tmpdir handling>`.
@@ -203,5 +209,3 @@ Check out additional pytest resources to help you customize tests for your uniqu
* ":ref:`fixtures`" for providing a functional baseline to your tests
* ":ref:`plugins`" for managing and writing plugins
* ":ref:`goodpractices`" for virtualenv and test layouts
.. include:: links.inc

View File

@@ -232,5 +232,4 @@ options. It will run tests against the installed package and not
against your source code checkout, helping to detect packaging
glitches.
.. include:: links.inc
.. _`venv`: https://docs.python.org/3/library/venv.html

View File

@@ -111,7 +111,7 @@ More details can be found in the `original PR <https://github.com/pytest-dev/pyt
.. note::
in a future major relase of pytest we will introduce class based markers,
in a future major release of pytest we will introduce class based markers,
at which point markers will no longer be limited to instances of :py:class:`Mark`.

BIN
doc/en/img/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -44,6 +44,8 @@ To execute it:
E + where 4 = inc(3)
test_sample.py:6: AssertionError
========================= short test summary info ==========================
FAILED test_sample.py::test_answer - assert 4 == 5
============================ 1 failed in 0.12s =============================
Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used.
@@ -92,7 +94,7 @@ It provide tools to raise money and share your finances in full transparency.
It is the platform of choice for individuals and companies that want to make one-time or
monthly donations directly to the project.
See more datails in the `pytest collective`_.
See more details in the `pytest collective`_.
.. _Open Collective: https://opencollective.com
.. _pytest collective: https://opencollective.com/pytest
@@ -112,7 +114,7 @@ Save time, reduce risk, and improve code health, while paying the maintainers of
Security
^^^^^^^^
pytest has never been associated with a security vunerability, but in any case, to report a
pytest has never been associated with a security vulnerability, but in any case, to report a
security vulnerability please use the `Tidelift security contact <https://tidelift.com/security>`_.
Tidelift will coordinate the fix and disclosure.
@@ -120,7 +122,7 @@ Tidelift will coordinate the fix and disclosure.
License
-------
Copyright Holger Krekel and others, 2004-2017.
Copyright Holger Krekel and others, 2004-2020.
Distributed under the terms of the `MIT`_ license, pytest is free and open source software.

View File

@@ -9,7 +9,7 @@ Distributed under the terms of the `MIT`_ license, pytest is free and open sourc
The MIT License (MIT)
Copyright (c) 2004-2019 Holger Krekel and others
Copyright (c) 2004-2020 Holger Krekel and others
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View File

@@ -1,22 +0,0 @@
.. _`skipping plugin`: plugin/skipping.html
.. _`funcargs mechanism`: funcargs.html
.. _`doctest.py`: http://docs.python.org/library/doctest.html
.. _`xUnit style setup`: xunit_setup.html
.. _`pytest_nose`: plugin/nose.html
.. _`reStructured Text`: http://docutils.sourceforge.net
.. _`Python debugger`: http://docs.python.org/lib/module-pdb.html
.. _nose: https://nose.readthedocs.io/en/latest/
.. _pytest: https://pypi.org/project/pytest/
.. _mercurial: http://mercurial.selenic.com/wiki/
.. _`setuptools`: https://pypi.org/project/setuptools/
.. _`easy_install`:
.. _`distribute docs`:
.. _`distribute`: https://pypi.org/project/distribute/
.. _`pip`: https://pypi.org/project/pip/
.. _`venv`: https://docs.python.org/3/library/venv.html
.. _`virtualenv`: https://pypi.org/project/virtualenv/
.. _hudson: http://hudson-ci.org/
.. _jenkins: http://jenkins-ci.org/
.. _tox: http://testrun.org/tox
.. _pylib: https://py.readthedocs.io/en/latest/

View File

@@ -3,8 +3,6 @@
Running tests written for nose
=======================================
.. include:: links.inc
``pytest`` has basic support for running tests written for nose_.
.. _nosestyle:
@@ -72,3 +70,5 @@ Unsupported idioms / known issues
There are no plans to fix this currently because ``yield``-tests
are deprecated in pytest 3.0, with ``pytest.mark.parametrize``
being the recommended alternative.
.. _nose: https://nose.readthedocs.io/en/latest/

View File

@@ -75,6 +75,8 @@ them in turn:
E + where 54 = eval('6*9')
test_expectation.py:6: AssertionError
========================= short test summary info ==========================
FAILED test_expectation.py::test_eval[6*9-42] - AssertionError: assert 54...
======================= 1 failed, 2 passed in 0.12s ========================
.. note::
@@ -225,6 +227,8 @@ Let's also run with a stringinput that will lead to a failing test:
E + where <built-in method isalpha of str object at 0xdeadbeef> = '!'.isalpha
test_strings.py:4: AssertionError
========================= short test summary info ==========================
FAILED test_strings.py::test_valid_string[!] - AssertionError: assert False
1 failed in 0.12s
As expected our test function fails.

View File

@@ -41,8 +41,7 @@ Here is a little annotated list for some popular plugins:
* `pytest-instafail <https://pypi.org/project/pytest-instafail/>`_:
to report failures while the test run is happening.
* `pytest-bdd <https://pypi.org/project/pytest-bdd/>`_ and
`pytest-konira <https://pypi.org/project/pytest-konira/>`_
* `pytest-bdd <https://pypi.org/project/pytest-bdd/>`_:
to write tests using behaviour-driven testing.
* `pytest-timeout <https://pypi.org/project/pytest-timeout/>`_:

View File

@@ -72,8 +72,7 @@ Some organisations using pytest
-----------------------------------
* `Square Kilometre Array, Cape Town <http://ska.ac.za/>`_
* `Some Mozilla QA people <http://www.theautomatedtester.co.uk/blog/2011/pytest_and_xdist_plugin.html>`_ use pytest to distribute their Selenium tests
* `Tandberg <http://www.tandberg.com/>`_
* `Some Mozilla QA people <https://www.theautomatedtester.co.uk/blog/2011/pytest_and_xdist_plugin/>`_ use pytest to distribute their Selenium tests
* `Shootq <http://web.shootq.com/>`_
* `Stups department of Heinrich Heine University Duesseldorf <http://www.stups.uni-duesseldorf.de/projects.php>`_
* cellzome

View File

@@ -1,31 +1,97 @@
Python 2.7 and 3.4 support plan
===============================
Python 2.7 and 3.4 support
==========================
Python 2.7 EOL is fast approaching, with
upstream support `ending in 2020 <https://legacy.python.org/dev/peps/pep-0373/#id4>`__.
Python 3.4's last release is scheduled for
`March 2019 <https://www.python.org/dev/peps/pep-0429/#release-schedule>`__. pytest is one of
the participating projects of the https://python3statement.org.
It is demanding on the maintainers of an open source project to support many Python versions, as
there's extra cost of keeping code compatible between all versions, while holding back on
features only made possible on newer Python versions.
The **pytest 4.6** series is the last to support Python 2.7 and 3.4, and was released in
**June 2019**. **pytest 5.0** and onwards will support only Python 3.5+.
In case of Python 2 and 3, the difference between the languages makes it even more prominent,
because many new Python 3 features cannot be used in a Python 2/3 compatible code base.
Thanks to the `python_requires`_ ``setuptools`` option,
Python 2.7 and Python 3.4 users using a modern ``pip`` version
will install the last pytest ``4.6`` version automatically even if ``5.0`` or later
Python 2.7 EOL has been reached `in 2020 <https://legacy.python.org/dev/peps/pep-0373/#id4>`__, with
the last release planned for mid-April, 2020.
Python 3.4 EOL has been reached `in 2019 <https://www.python.org/dev/peps/pep-0429/#release-schedule>`__, with the last release made in March, 2019.
For those reasons, in Jun 2019 it was decided that **pytest 4.6** series will be the last to support Python 2.7 and 3.4.
What this means for general users
---------------------------------
Thanks to the `python_requires`_ setuptools option,
Python 2.7 and Python 3.4 users using a modern pip version
will install the last pytest 4.6.X version automatically even if 5.0 or later versions
are available on PyPI.
While pytest ``5.0`` will be the new mainstream and development version, until **January 2020**
the pytest core team plans to make bug-fix releases of the pytest ``4.6`` series by
back-porting patches to the ``4.6-maintenance`` branch that affect Python 2 users.
Users should ensure they are using the latest pip and setuptools versions for this to work.
**After 2020**, the core team will no longer actively backport patches, but the ``4.6-maintenance``
branch will continue to exist so the community itself can contribute patches. The core team will
be happy to accept those patches and make new ``4.6`` releases **until mid-2020**.
Maintenance of 4.6.X versions
-----------------------------
Until January 2020, the pytest core team ported many bug-fixes from the main release into the
``4.6.x`` branch, with several 4.6.X releases being made along the year.
From now on, the core team will **no longer actively backport patches**, but the ``4.6.x``
branch will continue to exist so the community itself can contribute patches.
The core team will be happy to accept those patches, and make new 4.6.X releases **until mid-2020**
(but consider that date as a ballpark, after that date the team might still decide to make new releases
for critical bugs).
.. _`python_requires`: https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
Technical Aspects
-----------------
Technical aspects
~~~~~~~~~~~~~~~~~
The technical aspects of the Python 2.7 and 3.4 support plan (such as when releases will occurr, how to backport fixes, etc) is described in issue `#5275 <https://github.com/pytest-dev/pytest/issues/5275>`__.
(This section is a transcript from `#5275 <https://github.com/pytest-dev/pytest/issues/5275>`__).
In this section we describe the technical aspects of the Python 2.7 and 3.4 support plan.
What goes into 4.6.X releases
+++++++++++++++++++++++++++++
New 4.6.X releases will contain bug fixes only.
When will 4.6.X releases happen
+++++++++++++++++++++++++++++++
New 4.6.X releases will happen after we have a few bugs in place to release, or if a few weeks have
passed (say a single bug has been fixed a month after the latest 4.6.X release).
No hard rules here, just ballpark.
Who will handle applying bug fixes
++++++++++++++++++++++++++++++++++
We core maintainers expect that people still using Python 2.7/3.4 and being affected by
bugs to step up and provide patches and/or port bug fixes from the active branches.
We will be happy to guide users interested in doing so, so please don't hesitate to ask.
**Backporting changes into 4.6**
Please follow these instructions:
#. ``git fetch --all --prune``
#. ``git checkout origin/4.6.x -b backport-XXXX`` # use the PR number here
#. Locate the merge commit on the PR, in the *merged* message, for example:
nicoddemus merged commit 0f8b462 into pytest-dev:features
#. ``git cherry-pick -m1 REVISION`` # use the revision you found above (``0f8b462``).
#. Open a PR targeting ``4.6.x``:
* Prefix the message with ``[4.6]`` so it is an obvious backport
* Delete the PR body, it usually contains a duplicate commit message.
**Providing new PRs to 4.6**
Fresh pull requests to ``4.6.x`` will be accepted provided that
the equivalent code in the active branches does not contain that bug (for example, a bug is specific
to Python 2 only).
Bug fixes that also happen in the mainstream version should be first fixed
there, and then backported as per instructions above.

View File

@@ -77,6 +77,8 @@ This is also discussed in details in :ref:`test discovery`.
Invoking ``pytest`` versus ``python -m pytest``
-----------------------------------------------
Running pytest with ``python -m pytest [...]`` instead of ``pytest [...]`` yields nearly
equivalent behaviour, except that the former call will add the current directory to ``sys.path``.
Running pytest with ``pytest [...]`` instead of ``python -m pytest [...]`` yields nearly
equivalent behaviour, except that the latter will add the current directory to ``sys.path``, which
is standard ``python`` behavior.
See also :ref:`cmdline`.

View File

@@ -1,3 +1,5 @@
.. _`reference`:
API Reference
=============
@@ -124,7 +126,7 @@ Add warning filters to marked test items.
.. code-block:: python
@pytest.mark.warnings("ignore:.*usage will be deprecated.*:DeprecationWarning")
@pytest.mark.filterwarnings("ignore:.*usage will be deprecated.*:DeprecationWarning")
def test_foo():
...
@@ -241,6 +243,8 @@ Will create and attach a :class:`Mark <_pytest.mark.structures.Mark>` object to
mark.kwargs == {"method": "thread"}
.. _`fixtures-api`:
Fixtures
--------
@@ -271,6 +275,8 @@ Example of a fixture requiring another fixture:
For more details, consult the full :ref:`fixtures docs <fixture>`.
.. _`pytest.fixture-api`:
@pytest.fixture
~~~~~~~~~~~~~~~
@@ -278,7 +284,7 @@ For more details, consult the full :ref:`fixtures docs <fixture>`.
:decorator:
.. _`cache-api`:
.. fixture:: config.cache
config.cache
~~~~~~~~~~~~
@@ -299,6 +305,8 @@ Under the hood, the cache plugin uses the simple
.. automethod:: Cache.makedir
.. fixture:: capsys
capsys
~~~~~~
@@ -324,6 +332,8 @@ capsys
:members:
.. fixture:: capsysbinary
capsysbinary
~~~~~~~~~~~~
@@ -344,6 +354,8 @@ capsysbinary
assert captured.out == b"hello\n"
.. fixture:: capfd
capfd
~~~~~~
@@ -360,10 +372,12 @@ capfd
def test_system_echo(capfd):
os.system('echo "hello"')
captured = capsys.readouterr()
captured = capfd.readouterr()
assert captured.out == "hello\n"
.. fixture:: capfdbinary
capfdbinary
~~~~~~~~~~~~
@@ -384,6 +398,8 @@ capfdbinary
assert captured.out == b"hello\n"
.. fixture:: doctest_namespace
doctest_namespace
~~~~~~~~~~~~~~~~~
@@ -402,6 +418,8 @@ doctest_namespace
For more details: :ref:`doctest_namespace`.
.. fixture:: request
request
~~~~~~~
@@ -413,12 +431,16 @@ The ``request`` fixture is a special fixture providing information of the reques
:members:
.. fixture:: pytestconfig
pytestconfig
~~~~~~~~~~~~
.. autofunction:: _pytest.fixtures.pytestconfig()
.. fixture:: record_property
record_property
~~~~~~~~~~~~~~~~~~~
@@ -427,6 +449,8 @@ record_property
.. autofunction:: _pytest.junitxml.record_property()
.. fixture:: record_testsuite_property
record_testsuite_property
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -434,6 +458,9 @@ record_testsuite_property
.. autofunction:: _pytest.junitxml.record_testsuite_property()
.. fixture:: caplog
caplog
~~~~~~
@@ -448,6 +475,8 @@ caplog
:members:
.. fixture:: monkeypatch
monkeypatch
~~~~~~~~~~~
@@ -463,6 +492,9 @@ monkeypatch
.. autoclass:: _pytest.monkeypatch.MonkeyPatch
:members:
.. fixture:: testdir
testdir
~~~~~~~
@@ -489,6 +521,8 @@ To use it, include in your top-most ``conftest.py`` file:
:members:
.. fixture:: recwarn
recwarn
~~~~~~~
@@ -512,6 +546,8 @@ Each recorded warning is an instance of :class:`warnings.WarningMessage`.
differently; see :ref:`ensuring_function_triggers`.
.. fixture:: tmp_path
tmp_path
~~~~~~~~
@@ -523,6 +559,8 @@ tmp_path
:no-auto-options:
.. fixture:: tmp_path_factory
tmp_path_factory
~~~~~~~~~~~~~~~~
@@ -538,6 +576,8 @@ tmp_path_factory
.. automethod:: TempPathFactory.getbasetemp
.. fixture:: tmpdir
tmpdir
~~~~~~
@@ -549,6 +589,8 @@ tmpdir
:no-auto-options:
.. fixture:: tmpdir_factory
tmpdir_factory
~~~~~~~~~~~~~~
@@ -734,7 +776,7 @@ ExceptionInfo
pytest.ExitCode
~~~~~~~~~~~~~~~
.. autoclass:: _pytest.main.ExitCode
.. autoclass:: _pytest.config.ExitCode
:members:
@@ -897,8 +939,8 @@ Can be either a ``str`` or ``Sequence[str]``.
pytest_plugins = ("myapp.testsupport.tools", "myapp.testsupport.regression")
pytest_mark
~~~~~~~~~~~
pytestmark
~~~~~~~~~~
**Tutorial**: :ref:`scoped-marking`
@@ -1160,9 +1202,17 @@ passed multiple times. The expected format is ``name=value``. For example::
.. confval:: junit_logging
.. versionadded:: 3.5
.. versionchanged:: 5.4
``log``, ``all``, ``out-err`` options added.
Configures if stdout/stderr should be written to the JUnit XML file. Valid values are
``system-out``, ``system-err``, and ``no`` (the default).
Configures if captured output should be written to the JUnit XML file. Valid values are:
* ``log``: write only ``logging`` captured output.
* ``system-out``: write captured ``stdout`` contents.
* ``system-err``: write captured ``stderr`` contents.
* ``out-err``: write both captured ``stdout`` and ``stderr`` contents.
* ``all``: write captured ``logging``, ``stdout`` and ``stderr`` contents.
* ``no`` (the default): no captured output is written.
.. code-block:: ini
@@ -1192,6 +1242,38 @@ passed multiple times. The expected format is ``name=value``. For example::
[pytest]
junit_suite_name = my_suite
.. confval:: log_auto_indent
Allow selective auto-indentation of multiline log messages.
Supports command line option ``--log-auto-indent [value]``
and config option ``log_auto_indent = [value]`` to set the
auto-indentation behavior for all logging.
``[value]`` can be:
* True or "On" - Dynamically auto-indent multiline log messages
* False or "Off" or 0 - Do not auto-indent multiline log messages (the default behavior)
* [positive integer] - auto-indent multiline log messages by [value] spaces
.. code-block:: ini
[pytest]
log_auto_indent = False
Supports passing kwarg ``extra={"auto_indent": [value]}`` to
calls to ``logging.log()`` to specify auto-indentation behavior for
a specific entry in the log. ``extra`` kwarg overrides the value specified
on the command line or in the config.
.. confval:: log_cli
Enable log display during test run (also known as :ref:`"live logging" <live_logs>`).
The default is ``False``.
.. code-block:: ini
[pytest]
log_cli = True
.. confval:: log_cli_date_format

View File

@@ -234,11 +234,11 @@ expect a test to fail:
def test_function():
...
This test will be run but no traceback will be reported
when it fails. Instead terminal reporting will list it in the
"expected to fail" (``XFAIL``) or "unexpectedly passing" (``XPASS``) sections.
This test will run but no traceback will be reported when it fails. Instead, terminal
reporting will list it in the "expected to fail" (``XFAIL``) or "unexpectedly
passing" (``XPASS``) sections.
Alternatively, you can also mark a test as ``XFAIL`` from within a test or setup function
Alternatively, you can also mark a test as ``XFAIL`` from within the test or its setup function
imperatively:
.. code-block:: python
@@ -247,8 +247,19 @@ imperatively:
if not valid_config():
pytest.xfail("failing configuration (but should work)")
This will unconditionally make ``test_function`` ``XFAIL``. Note that no other code is executed
after ``pytest.xfail`` call, differently from the marker. That's because it is implemented
.. code-block:: python
def test_function2():
import slow_module
if slow_module.slow_function():
pytest.xfail("slow_module taking too long")
These two examples illustrate situations where you don't want to check for a condition
at the module level, which is when a condition would otherwise be evaluated for marks.
This will make ``test_function`` ``XFAIL``. Note that no other code is executed after
the ``pytest.xfail`` call, differently from the marker. That's because it is implemented
internally by raising a known exception.
**Reference**: :ref:`pytest.mark.xfail ref`
@@ -261,8 +272,8 @@ internally by raising a known exception.
Both ``XFAIL`` and ``XPASS`` don't fail the test suite, unless the ``strict`` keyword-only
parameter is passed as ``True``:
Both ``XFAIL`` and ``XPASS`` don't fail the test suite by default.
You can change this by setting the ``strict`` keyword-only parameter to ``True``:
.. code-block:: python

View File

@@ -17,7 +17,7 @@ It provide tools to raise money and share your finances in full transparency.
It is the platform of choice for individuals and companies that want to make one-time or
monthly donations directly to the project.
See more datails in the `pytest collective`_.
See more details in the `pytest collective`_.
.. _Tidelift: https://tidelift.com

View File

@@ -42,7 +42,7 @@ Talks and blog postings
<https://www.youtube.com/watch?v=P-AhpukDIik>`_
- `3-part blog series about pytest from @pydanny alias Daniel Greenfeld (January
2014) <http://pydanny.com/pytest-no-boilerplate-testing.html>`_
2014) <https://daniel.roygreenfeld.com/pytest-no-boilerplate-testing.html>`_
- `pytest: helps you write better Django apps, Andreas Pelme, DjangoCon
Europe 2014 <https://www.youtube.com/watch?v=aaArYVh6XSM>`_.
@@ -64,7 +64,7 @@ Talks and blog postings
- `pytest introduction from Brian Okken (January 2013)
<http://pythontesting.net/framework/pytest-introduction/>`_
- pycon australia 2012 pytest talk from Brianna Laugher (`video <http://www.youtube.com/watch?v=DTNejE9EraI>`_, `slides <http://www.slideshare.net/pfctdayelise/funcargs-other-fun-with-pytest>`_, `code <https://gist.github.com/3386951>`_)
- pycon australia 2012 pytest talk from Brianna Laugher (`video <http://www.youtube.com/watch?v=DTNejE9EraI>`_, `slides <https://www.slideshare.net/pfctdayelise/funcargs-other-fun-with-pytest>`_, `code <https://gist.github.com/3386951>`_)
- `pycon 2012 US talk video from Holger Krekel <http://www.youtube.com/watch?v=9LVqBQcFmyw>`_
- `monkey patching done right`_ (blog post, consult `monkeypatch plugin`_ for up-to-date API)

View File

@@ -64,6 +64,8 @@ Running this would result in a passed test except for the last
E assert 0
test_tmp_path.py:13: AssertionError
========================= short test summary info ==========================
FAILED test_tmp_path.py::test_create_file - assert 0
============================ 1 failed in 0.12s =============================
.. _`tmp_path_factory example`:
@@ -133,6 +135,8 @@ Running this would result in a passed test except for the last
E assert 0
test_tmpdir.py:9: AssertionError
========================= short test summary info ==========================
FAILED test_tmpdir.py::test_create_file - assert 0
============================ 1 failed in 0.12s =============================
.. _`tmpdir factory example`:

View File

@@ -166,6 +166,9 @@ the ``self.db`` values in the traceback:
E assert 0
test_unittest_db.py:13: AssertionError
========================= short test summary info ==========================
FAILED test_unittest_db.py::MyTest::test_method1 - AssertionError: <conft...
FAILED test_unittest_db.py::MyTest::test_method2 - AssertionError: <conft...
============================ 2 failed in 0.12s =============================
This default pytest traceback shows that the two test methods
@@ -238,17 +241,6 @@ was executed ahead of the ``test_method``.
.. _pdb-unittest-note:
.. note::
Running tests from ``unittest.TestCase`` subclasses with ``--pdb`` will
disable tearDown and cleanup methods for the case that an Exception
occurs. This allows proper post mortem debugging for all applications
which have significant logic in their tearDown machinery. However,
supporting this feature has the following side effect: If people
overwrite ``unittest.TestCase`` ``__call__`` or ``run``, they need to
to overwrite ``debug`` in the same way (this is also true for standard
unittest).
.. note::
Due to architectural differences between the two frameworks, setup and

View File

@@ -33,7 +33,7 @@ Running ``pytest`` can result in six different exit codes:
:Exit code 4: pytest command line usage error
:Exit code 5: No tests were collected
They are represented by the :class:`_pytest.main.ExitCode` enum. The exit codes being a part of the public API can be imported and accessed directly using:
They are represented by the :class:`_pytest.config.ExitCode` enum. The exit codes being a part of the public API can be imported and accessed directly using:
.. code-block:: python
@@ -66,8 +66,8 @@ To stop the testing process after the first (N) failures:
.. code-block:: bash
pytest -x # stop after first failure
pytest --maxfail=2 # stop after two failures
pytest -x # stop after first failure
pytest --maxfail=2 # stop after two failures
.. _select-tests:
@@ -94,8 +94,8 @@ Pytest supports several ways to run and select tests from the command-line.
pytest -k "MyClass and not method"
This will run tests which contain names that match the given *string expression*, which can
include Python operators that use filenames, class names and function names as variables.
This will run tests which contain names that match the given *string expression* (case-insensitive),
which can include Python operators that use filenames, class names and function names as variables.
The example above will run ``TestMyClass.test_something`` but not ``TestMyClass.test_method_simple``.
.. _nodeids:
@@ -169,11 +169,11 @@ option you make sure a trace is shown.
Detailed summary report
-----------------------
The ``-r`` flag can be used to display a "short test summary info" at the end of the test session,
making it easy in large test suites to get a clear picture of all failures, skips, xfails, etc.
It defaults to ``fE`` to list failures and errors.
Example:
.. code-block:: python
@@ -241,7 +241,7 @@ Example:
test_example.py:14: AssertionError
========================= short test summary info ==========================
SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:23: skipping this test
SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:22: skipping this test
XFAIL test_example.py::test_xfail
reason: xfailing this test
XPASS test_example.py::test_xpass always xfail
@@ -261,8 +261,12 @@ Here is the full list of available characters that can be used:
- ``X`` - xpassed
- ``p`` - passed
- ``P`` - passed with output
Special characters for (de)selection of groups:
- ``a`` - all except ``pP``
- ``A`` - all
- ``N`` - none, this can be used to display nothing (since ``fE`` is the default)
More than one character can be used, so for example to only see failed and skipped tests, you can execute:
@@ -296,7 +300,7 @@ More than one character can be used, so for example to only see failed and skipp
test_example.py:14: AssertionError
========================= short test summary info ==========================
FAILED test_example.py::test_fail - assert 0
SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:23: skipping this test
SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:22: skipping this test
== 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s ===
Using ``p`` lists the passing tests, whilst ``P`` adds an extra section "PASSES" with those tests that passed but had
@@ -679,12 +683,6 @@ Creating resultlog format files
----------------------------------------------------
This option is rarely used and is scheduled for removal in 5.0.
See `the deprecation docs <https://docs.pytest.org/en/latest/deprecations.html#result-log-result-log>`__
for more information.
To create plain-text machine-readable result files you can issue:
.. code-block:: bash
@@ -694,6 +692,16 @@ To create plain-text machine-readable result files you can issue:
and look at the content at the ``path`` location. Such files are used e.g.
by the `PyPy-test`_ web page to show test results over several revisions.
.. warning::
This option is rarely used and is scheduled for removal in pytest 6.0.
If you use this option, consider using the new `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__ plugin instead.
See `the deprecation docs <https://docs.pytest.org/en/latest/deprecations.html#result-log-result-log>`__
for more information.
.. _`PyPy-test`: http://buildbot.pypy.org/summary
@@ -813,6 +821,9 @@ hook was invoked:
E assert 0
test_example.py:14: AssertionError
========================= short test summary info ==========================
FAILED test_example.py::test_fail - assert 0
ERROR test_example.py::test_error - assert 0
.. note::
@@ -823,5 +834,4 @@ hook was invoked:
multiple calls to ``pytest.main()`` from the same process (in order to re-run
tests, for example) is not recommended.
.. include:: links.inc
.. _jenkins: http://jenkins-ci.org/

View File

@@ -41,7 +41,7 @@ Running pytest now produces this output:
warnings.warn(UserWarning("api v1, should use functions from v2"))
-- Docs: https://docs.pytest.org/en/latest/warnings.html
====================== 1 passed, 1 warnings in 0.12s =======================
======================= 1 passed, 1 warning in 0.12s =======================
The ``-W`` flag can be passed to control which warnings will be displayed or even turn
them into errors:
@@ -64,6 +64,8 @@ them into errors:
E UserWarning: api v1, should use functions from v2
test_show_warnings.py:5: UserWarning
========================= short test summary info ==========================
FAILED test_show_warnings.py::test_one - UserWarning: api v1, should use ...
1 failed in 0.12s
The same option can be set in the ``pytest.ini`` file using the ``filterwarnings`` ini option.
@@ -198,7 +200,7 @@ the regular expression ``".*U.*mode is deprecated"``.
Ensuring code triggers a deprecation warning
--------------------------------------------
You can also call a global helper for checking
You can also use :func:`pytest.deprecated_call` for checking
that a certain function call triggers a ``DeprecationWarning`` or
``PendingDeprecationWarning``:
@@ -207,13 +209,18 @@ that a certain function call triggers a ``DeprecationWarning`` or
import pytest
def test_global():
pytest.deprecated_call(myfunction, 17)
def test_myfunction_deprecated():
with pytest.deprecated_call():
myfunction(17)
This test will fail if ``myfunction`` does not issue a deprecation warning
when called with a ``17`` argument.
By default, ``DeprecationWarning`` and ``PendingDeprecationWarning`` will not be
caught when using ``pytest.warns`` or ``recwarn`` because default Python warnings filters hide
them. If you wish to record them in your own code, use the
command ``warnings.simplefilter('always')``:
caught when using :func:`pytest.warns` or :ref:`recwarn <recwarn>` because
the default Python warnings filters hide
them. If you wish to record them in your own code, use
``warnings.simplefilter('always')``:
.. code-block:: python
@@ -223,19 +230,13 @@ command ``warnings.simplefilter('always')``:
def test_deprecation(recwarn):
warnings.simplefilter("always")
warnings.warn("deprecated", DeprecationWarning)
myfunction(17)
assert len(recwarn) == 1
assert recwarn.pop(DeprecationWarning)
You can also use it as a contextmanager:
.. code-block:: python
def test_global():
with pytest.deprecated_call():
myobject.deprecated_method()
The :ref:`recwarn <recwarn>` fixture automatically ensures to reset the warnings
filter at the end of the test, so no global state is leaked.
.. _`asserting warnings`:
@@ -407,7 +408,7 @@ defines an ``__init__`` constructor, as this prevents the class from being insta
class Test:
-- Docs: https://docs.pytest.org/en/latest/warnings.html
1 warnings in 0.12s
1 warning in 0.12s
These warnings might be filtered using the same builtin mechanisms used to filter other types of warnings.

View File

@@ -179,11 +179,12 @@ assertion failures. This is provided by "assertion rewriting" which
modifies the parsed AST before it gets compiled to bytecode. This is
done via a :pep:`302` import hook which gets installed early on when
``pytest`` starts up and will perform this rewriting when modules get
imported. However since we do not want to test different bytecode
then you will run in production this hook only rewrites test modules
themselves as well as any modules which are part of plugins. Any
other imported module will not be rewritten and normal assertion
behaviour will happen.
imported. However, since we do not want to test different bytecode
from what you will run in production, this hook only rewrites test modules
themselves (as defined by the :confval:`python_files` configuration option),
and any modules which are part of plugins.
Any other imported module will not be rewritten and normal assertion behaviour
will happen.
If you have assertion helpers in other modules where you would need
assertion rewriting to be enabled you need to ask ``pytest``
@@ -441,8 +442,13 @@ additionally it is possible to copy examples for an example folder before runnin
$REGENDOC_TMPDIR/test_example.py:4: PytestExperimentalApiWarning: testdir.copy_example is an experimental api that may change over time
testdir.copy_example("test_example.py")
test_example.py::test_plugin
$PYTHON_PREFIX/lib/python3.8/site-packages/_pytest/compat.py:333: PytestDeprecationWarning: The TerminalReporter.writer attribute is deprecated, use TerminalReporter._tw instead at your own risk.
See https://docs.pytest.org/en/latest/deprecations.html#terminalreporter-writer for more information.
return getattr(object, name, default)
-- Docs: https://docs.pytest.org/en/latest/warnings.html
====================== 2 passed, 1 warnings in 0.12s =======================
====================== 2 passed, 2 warnings in 0.12s =======================
For more information about the result object that ``runpytest()`` returns, and
the methods that it provides please check out the :py:class:`RunResult
@@ -677,6 +683,56 @@ Example:
print(config.hook)
.. _`addoptionhooks`:
Using hooks in pytest_addoption
-------------------------------
Occasionally, it is necessary to change the way in which command line options
are defined by one plugin based on hooks in another plugin. For example,
a plugin may expose a command line option for which another plugin needs
to define the default value. The pluginmanager can be used to install and
use hooks to accomplish this. The plugin would define and add the hooks
and use pytest_addoption as follows:
.. code-block:: python
# contents of hooks.py
# Use firstresult=True because we only want one plugin to define this
# default value
@hookspec(firstresult=True)
def pytest_config_file_default_value():
""" Return the default value for the config file command line option. """
# contents of myplugin.py
def pytest_addhooks(pluginmanager):
""" This example assumes the hooks are grouped in the 'hooks' module. """
from . import hook
pluginmanager.add_hookspecs(hook)
def pytest_addoption(parser, pluginmanager):
default_value = pluginmanager.hook.pytest_config_file_default_value()
parser.addoption(
"--config-file",
help="Config file to use, defaults to %(default)s",
default=default_value,
)
The conftest.py that is using myplugin would simply define the hook as follows:
.. code-block:: python
def pytest_config_file_default_value():
return "config.yaml"
Optionally using hooks from 3rd party plugins
---------------------------------------------

View File

@@ -10,14 +10,14 @@ build-backend = "setuptools.build_meta"
[tool.towncrier]
package = "pytest"
package_dir = "src"
filename = "CHANGELOG.rst"
filename = "doc/en/changelog.rst"
directory = "changelog/"
title_format = "pytest {version} ({project_date})"
template = "changelog/_template.rst"
[[tool.towncrier.type]]
directory = "removal"
name = "Removals"
directory = "breaking"
name = "Breaking Changes"
showcontent = true
[[tool.towncrier.type]]
@@ -54,3 +54,6 @@ template = "changelog/_template.rst"
directory = "trivial"
name = "Trivial/Internal Changes"
showcontent = true
[tool.black]
target-version = ['py35']

View File

@@ -0,0 +1,36 @@
"""
Appends the codecov token to the 'codecov.yml' file at the root of the repository.
This is done by CI during PRs and builds on the pytest-dev repository so we can upload coverage, at least
until codecov grows some native integration like it has with Travis and AppVeyor.
See discussion in https://github.com/pytest-dev/pytest/pull/6441 for more information.
"""
import os.path
from textwrap import dedent
def main():
this_dir = os.path.dirname(__file__)
cov_file = os.path.join(this_dir, "..", "codecov.yml")
assert os.path.isfile(cov_file), "{cov_file} does not exist".format(
cov_file=cov_file
)
with open(cov_file, "a") as f:
# token from: https://codecov.io/gh/pytest-dev/pytest/settings
# use same URL to regenerate it if needed
text = dedent(
"""
codecov:
token: "1eca3b1f-31a2-4fb8-a8c3-138b441b50a7"
"""
)
f.write(text)
print("Token updated:", cov_file)
if __name__ == "__main__":
main()

View File

@@ -6,7 +6,13 @@ This script is meant to be executed after a successful deployment in Travis.
Uses the following environment variables:
* GIT_TAG: the name of the tag of the current commit.
* GH_RELEASE_NOTES_TOKEN: a personal access token with 'repo' permissions. It should be encrypted using:
* GH_RELEASE_NOTES_TOKEN: a personal access token with 'repo' permissions.
Create one at:
https://github.com/settings/tokens
It should be encrypted using:
$travis encrypt GH_RELEASE_NOTES_TOKEN=<token> -r pytest-dev/pytest
@@ -33,7 +39,7 @@ def publish_github_release(slug, token, tag_name, body):
def parse_changelog(tag_name):
p = Path(__file__).parent.parent / "CHANGELOG.rst"
p = Path(__file__).parent.parent / "doc/en/changelog.rst"
changelog_lines = p.read_text(encoding="UTF-8").splitlines()
title_regex = re.compile(r"pytest (\d\.\d+\.\d+) \(\d{4}-\d{2}-\d{2}\)")
@@ -55,26 +61,30 @@ def parse_changelog(tag_name):
def convert_rst_to_md(text):
return pypandoc.convert_text(text, "md", format="rst")
return pypandoc.convert_text(
text, "md", format="rst", extra_args=["--wrap=preserve"]
)
def main(argv):
if len(argv) > 1:
tag_name = argv[1]
else:
tag_name = os.environ.get("TRAVIS_TAG")
tag_name = os.environ.get("GITHUB_REF")
if not tag_name:
print("tag_name not given and $TRAVIS_TAG not set", file=sys.stderr)
print("tag_name not given and $GITHUB_REF not set", file=sys.stderr)
return 1
if tag_name.startswith("refs/tags/"):
tag_name = tag_name[len("refs/tags/") :]
token = os.environ.get("GH_RELEASE_NOTES_TOKEN")
if not token:
print("GH_RELEASE_NOTES_TOKEN not set", file=sys.stderr)
return 1
slug = os.environ.get("TRAVIS_REPO_SLUG")
slug = os.environ.get("GITHUB_REPOSITORY")
if not slug:
print("TRAVIS_REPO_SLUG not set", file=sys.stderr)
print("GITHUB_REPOSITORY not set", file=sys.stderr)
return 1
rst_body = parse_changelog(tag_name)

Some files were not shown because too many files have changed in this diff Show More