Ran Benita
0242de4f56
Format docstrings in a consistent style
2020-08-01 17:14:37 +03:00
Bruno Oliveira
6882c0368b
Merge pull request #7593 from bluetech/typing-no-implicit-reexport
...
typing: set no_implicit_reexport
2020-08-01 11:03:47 -03:00
Ran Benita
8d98de8f8a
typing: set no_implicit_reexport
...
In Python, if module A defines a name `name`, and module B does `import
name from A`, then another module C can `import name from B`.
Sometimes it is intentional -- module B is meant to "reexport" `name`.
But sometimes it is just confusion/inconsistency on where `name` should
be imported from.
mypy has a flag `--no-implicit-reexport` which puts some order into
this. A name can only be imported from a module if
1. The module defines the name
2. The module's `__all__` includes the name
3. The module imports the name as `from ... import .. as name`.
This flag is included in mypy's `--strict` flag.
I like this flag, but I realize it is a bit controversial, and in
particular item 3 above is a bit unfriendly to contributors who don't
know about it. So I didn't intend to add it to pytest.
But while investigating issue 7589 I came upon mypy issue 8754 which
causes `--no-implicit-reexport` to leak into installed libraries and
causes some unexpected typing differences *in pytest* if the user uses
this flag.
Since the diff mostly makes sense, let's just conform to it.
2020-07-31 10:09:11 +03:00
Ran Benita
96a48f0c66
Stop using more-itertools
...
We barely use it; the couple places that do are not really worth the
extra dependency, I think the code is clearer without it.
Also simplifies one (regular) itertools usage.
Also improves a check and an error message in `pytest.raises`.
2020-07-30 20:19:24 +03:00
Bruno Oliveira
095bf191e2
Merge pull request #7561 from nicoddemus/longreprtext-7559
2020-07-29 09:47:04 -03:00
Bruno Oliveira
d3267bc49d
Fix TestReport.longreprtext when TestReport.longrepr is not a string
...
Fix #7559
2020-07-29 09:31:15 -03:00
Ran Benita
0e0275d8d9
logging: fix capture handler level not reset on teardown after caplog.set_level()
...
This probably regressed in fcbaab8
.
2020-07-29 14:59:29 +03:00
Ran Benita
b473e515bc
Merge pull request #7541 from bluetech/py-visit
...
pathlib: stop using py.path.local.visit(), use os.scandir
2020-07-29 12:04:06 +03:00
Ran Benita
f86e4516eb
junitxml: convert from py.xml to xml.etree.ElementTree
...
Part of the effort to reduce dependency on the py library.
Besides that, py.xml implements its own XML serialization which is
pretty scary.
I tried to keep the code with minimal changes (though it could use some
cleanups). The differences in behavior I have noticed are:
- Attributes in the output are not sorted.
- Some unneeded escaping is no longer performed, for example escaping
`"` to `"` in a text node.
2020-07-29 10:52:21 +03:00
hp310780
27a4c6cd6d
Fix --help crash on add_ini(.., help='') and improve message on help=None ( #7427 )
2020-07-29 10:48:38 +03:00
Ran Benita
c15bb5d3de
pathlib: replace py.path.local.visit() with our own function
...
Part of reducing dependency on `py`. Also enables upcoming improvements.
In cases where there are simpler alternatives (in tests), I used those.
What's left are a couple of uses in `_pytest.main` and `_pytest.python`
and they only have modest requirements, so all of the featureful code
from py is not needed.
2020-07-25 00:26:49 +03:00
Zac Hatfield-Dodds
3a060b77e8
Revert change to traceback repr ( #7535 )
...
* Revert change to traceback repr
* Add test and changelog entry
* Restore *exact* prev output
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-07-24 13:30:38 +02:00
Bruno Oliveira
7ec6401ffa
Change pytest deprecation warnings into errors for 6.0 release ( #7362 )
...
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-07-22 21:36:51 -03:00
Bruno Oliveira
2a8dcc9728
Merge pull request #7526 from bluetech/win-bash-2
...
testing: improve bash check
2020-07-21 23:02:05 -03:00
Ran Benita
0709305953
testing: improve bash check
2020-07-21 21:21:09 +03:00
Anthony Sottile
8616a5f1d9
Preserve newlines when captured with capfd
2020-07-20 10:31:20 -07:00
Ran Benita
41d211c24a
testing: use a tighter check if `bash` is available ( #7520 )
...
This fixes CI on Windows since GitHub Actions started installing WSL on
their images which apparently installs some wrapper `bash` which does
not run actual bash.
2020-07-20 16:24:39 +02:00
Lewis Cowles
71ab6236a1
Clearer guidance on pytest.raise(match=...) failure ( #7499 )
2020-07-15 22:26:47 +03:00
Bruno Oliveira
e7c42ae62b
Inaccessible lock files now imply temporary directories can't be removed
...
Fix #7500
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-07-15 09:25:17 -03:00
Ran Benita
41c40efe80
Merge pull request #7496 from bluetech/typing-idfn
...
Fix typing of params ids callable form
2020-07-15 10:25:46 +03:00
Ran Benita
bc17034a67
Fix typing of params ids callable form
...
The previous typing had an object passed to the user, which they can't
do anything with without asserting, which is inconvenient. Change it to
Any instead.
Note that what comes *back* to pytest (the return value) should be an
`object`, because we want to handle arbitrary objects without assuming
anything about them.
2020-07-14 14:53:42 +03:00
Ran Benita
91f6892e6a
testing: add a file for checking no mypy errors
...
We probably something a bit more elaborate in the future but for now
it's something to verify fixes and catch regressions.
2020-07-14 14:37:59 +03:00
Ran Benita
ccad10a829
skipping: fix dynamic xfail mark added in runtest not respected
...
If a test runtest phase (not setup) dynamically adds a pytest.mark.xfail
mark to the item, it should be respected, but it wasn't. This regressed
in 3e6fe92b7e
(not released).
Fix it by just always refreshing the mark if needed. This is mostly what
was done before but in a more roundabout way.
2020-07-14 01:02:06 +03:00
Bruno Oliveira
07f5f6fd4a
Merge pull request #7481 from bluetech/tw-unicode-escape
...
terminalwriter: bring back handling of printing characters not supported by stdout
2020-07-11 16:01:45 -03:00
Simon K
7f467ebc9a
Create subdirectories if they do not exist when specified for log file ( #7468 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-07-11 13:40:28 -03:00
Ran Benita
7b65b2337b
Merge pull request #7472 from bluetech/cleanups-4
...
Some minor fixes & type annotations
2020-07-11 19:05:07 +03:00
Ran Benita
113339b029
terminalwriter: bring back handling of printing characters not supported by stdout
2020-07-11 18:59:00 +03:00
Hugo van Kemenade
c1c5a2b34a
Add support for NO_COLOR and FORCE_COLOR ( #7466 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-07-10 08:49:10 -03:00
Ran Benita
a2f021b6f3
Remove no longer needed `noqa: F821` uses
...
Not needed since pyflakes 2.2.0.
2020-07-10 13:08:56 +03:00
Ran Benita
bcff02c4c6
pytester: some type annotations
2020-07-10 13:08:56 +03:00
Ran Benita
e079ebbd57
python: more type annotations
2020-07-10 13:08:56 +03:00
Bruno Oliveira
be7b02c3b8
Make test_missing_required_plugins xdist-independent
...
Also cleaned up the parametrized list using `pytest.param` to assign ids
and removed some redundant cases.
Follow up to #7459
2020-07-09 22:09:28 -03:00
Arvin Firouzi
c3e2b11a62
Fix reported location of skip when --runxfail is used ( #7432 )
...
Co-authored-by: Arvin Firouzi <427014@student.fontys.nl>
2020-07-09 23:10:32 +03:00
Vlad-Radz
678c1a0745
assertion: improve diff output of recursive dataclass/attrs
...
Co-authored-by: Vlad <uladzislau.radziuk@nordcloud.com>
2020-07-08 19:04:56 +03:00
Bruno Oliveira
93d2ccbfb7
Point to stable docs instead of latest
...
Now that our master might contain new features, it is best to point
users to the stable docs rather than the latest
2020-07-07 07:45:27 -03:00
Ran Benita
36b958c99e
Merge pull request #7438 from bluetech/source-cleanups
...
code/source: some cleanups
2020-07-04 12:57:32 +03:00
Ran Benita
11efe057ea
testing: skip some unreachable code in coverage
2020-07-04 12:12:52 +03:00
Ran Benita
f76ac4c570
Merge pull request #7437 from bluetech/flaky-coroutine-never-awaited
...
testing: fix flaky tests due to "coroutine never awaited" warnings
2020-07-04 10:54:38 +03:00
Ran Benita
eced536eaf
Merge pull request #7435 from bluetech/python-cleanups
...
python: a few cleanups
2020-07-04 10:54:07 +03:00
Ran Benita
c8cfff6de5
testing: fix flaky tests due to "coroutine never awaited" warnings
...
They sometime leak into other test's warnings and cause them to fail.
2020-07-01 20:29:04 +03:00
Ran Benita
f5c69f3eb2
code/source: inline getsource()
...
The recursive way in which Source and getsource interact is a bit
confusing, just inline it.
2020-07-01 20:20:13 +03:00
Ran Benita
ef39115001
code/source: remove compiling functions
...
A lot of complex code that isn't used anymore outside of tests after
the previous commit.
2020-07-01 20:20:12 +03:00
Ran Benita
4a27d7d973
code/source: remove unused method Source.putaround()
2020-07-01 20:20:11 +03:00
Ran Benita
a7303b52db
code/source: remove unused method Source.isparseable()
2020-07-01 20:20:11 +03:00
Ran Benita
a127a22d13
code/source: remove support for comparing Source with str
...
Cross-type comparisons like this are a bad idea. This isn't used.
2020-07-01 20:20:10 +03:00
Ran Benita
4108174777
code/source: remove Source(deindent: bool) parameter
...
Not used, except in tests.
2020-07-01 20:20:07 +03:00
Ruaridh Williamson
304f2916fc
logging: use unique handlers for caplog and reports
...
Setting log_level via the CLI or .ini will control the log level of the
report that is dumped upon failure of a test.
If caplog modified the log level during the execution of that test, it
should not impact the level that is displayed upon failure in the
"captured log report" section.
[
ran:
- rebased
- reused handler
- changed store keys also to "caplog_handler_*"
- added changelog
all bugs are mine :)
]
2020-07-01 19:30:03 +03:00
Ran Benita
e492b1d567
python: don't pass entire Item for generating ID
...
Just the nodeid is enough for the error messages.
This removes an import cycle.
2020-06-30 13:13:45 +03:00
Gleb Nikonorov
72a39117a8
Merge remote-tracking branch 'origin' into issue_7295
2020-06-27 19:43:03 -04:00
Ran Benita
7450b6dd95
Merge pull request #7418 from bluetech/typing-3
...
More typing work
2020-06-27 10:54:29 +03:00
gdhameeja
03230b4002
Fix-6906: Added code-highlight option to disable highlighting optionally
...
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-26 13:24:56 -07:00
Ran Benita
1ae4182e18
testing: fix flaky tests on pypy3 due to resource warnings in stderr ( #7405 )
2020-06-26 09:50:19 -03:00
Ran Benita
8f8f472379
python_api: type annotate some parts of pytest.approx()
2020-06-25 15:15:24 +03:00
Ran Benita
4d813fdf5e
recwarn: improve return type annotation of non-contextmanager pytest.warns
...
It returns the return value of the function.
2020-06-25 14:30:42 +03:00
Ran Benita
f00bec2a12
Replace yield_fixture -> fixture in internal code
...
`yield_fixture` is a deprecated alias to `fixture`.
2020-06-25 14:05:46 +03:00
Gleb Nikonorov
0dd77b3e39
Merge remote-tracking branch 'origin/master' into issue_7295
2020-06-23 23:21:36 -04:00
David Diaz Barquero
617bf8be5b
Add details to error message for junit ( #7390 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-06-23 13:03:46 -03:00
Ran Benita
8994e1e3a1
config: make _get_plugin_specs_as_list a little clearer and more general
2020-06-23 11:47:52 +03:00
Ran Benita
4655b79985
config: improve typing
2020-06-22 16:39:14 +03:00
Ran Benita
83891d9022
Merge pull request #7387 from cool-RR/2020-06-11-raise-from
...
Fix exception causes all over the codebase
2020-06-21 22:42:18 +03:00
Gleb Nikonorov
33de350619
parametrize test_warn_missing for a cleaner test
2020-06-21 10:26:36 -04:00
Gleb Nikonorov
fe68c58698
add test_warn_missing case for --assert=plain
2020-06-20 13:06:41 -04:00
Gleb Nikonorov
a9d50aeab6
remove extra whitespace
2020-06-20 12:18:55 -04:00
Gleb Nikonorov
ac89d6532a
replace stderr warnings with the warnings module
2020-06-20 12:15:58 -04:00
Ran Benita
3e6fe92b7e
skipping: refactor skipif/xfail mark evaluation
...
Previously, skipif/xfail marks were evaluated using a `MarkEvaluator`
class. I found this class very difficult to understand.
Instead of `MarkEvaluator`, rewrite using straight functions which are
hopefully easier to follow.
I tried to keep the semantics exactly as before, except improving a few
error messages.
2020-06-20 16:15:28 +03:00
Ram Rachum
dd446bee5e
Fix exception causes all over the codebase
2020-06-19 22:02:24 +03:00
Gleb Nikonorov
4cc4ebf3c9
Don't treat ini keys defined in conftest.py as invalid ( #7384 )
2020-06-18 12:58:41 -03:00
Andrew
a67c553beb
Disable caching when evaluating expressions in marks ( #7373 )
2020-06-16 12:39:36 +03:00
Bruno Oliveira
db00612b84
Merge pull request #7364 from nicoddemus/parseoutcomes-plural-6505
...
assertoutcomes() only accepts plural forms
2020-06-15 20:27:40 -03:00
Ronny Pfannschmidt
4e5a7b7d2f
Merge pull request #7366 from gnikonorov/issue_7346
...
Allow users to provide version information to the required_plugins INI key
2020-06-15 20:19:05 +02:00
Gleb Nikonorov
320625527a
Add more tests and docs
2020-06-13 11:22:18 -04:00
Bruno Oliveira
ab6dacf1d1
Introduce --import-mode=importlib ( #7246 )
...
Fix #5821
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-13 11:29:01 -03:00
Bruno Oliveira
2c37585f58
Merge pull request #7258 from piotrhm/issue_6471
2020-06-13 11:14:18 -03:00
Gleb Nikonorov
7ea116d74c
Merge remote-tracking branch 'origin' into issue_7346
2020-06-13 09:54:23 -04:00
Bruno Oliveira
3151219785
assertoutcomes() only accepts plural forms
...
Fix #6505
2020-06-13 10:29:22 -03:00
Ran Benita
f551cab877
Merge pull request #7358 from bluetech/typing2
...
More type annotations, fix some typing bugs
2020-06-13 10:44:11 +03:00
Gleb Nikonorov
6f8633cc17
add in solution barring documentation
2020-06-13 02:47:15 -04:00
Bruno Oliveira
aaa6f1c3fa
Merge pull request #7330 from gnikonorov/issue_7305
2020-06-12 19:35:38 -03:00
Ran Benita
1cf9405075
Fix some type errors around py.path.local
...
These errors are found using a typed version of py.path.local.
2020-06-12 17:34:31 +03:00
Ran Benita
b4f046b777
monkeypatch: add type annotations
2020-06-12 17:34:31 +03:00
Ran Benita
f84ffd9747
Remove unused type: ignores
...
Not needed since update from mypy 0.770 -> 0.780.
2020-06-12 17:34:31 +03:00
Zac Hatfield-Dodds
0f30103d9c
Merge pull request #7356 from Zac-HD/emancipate
...
Finish deprecation of "slave"
2020-06-12 23:13:11 +10:00
Zac-HD
564b2f707d
Finish deprecation of "slave"
2020-06-12 22:49:33 +10:00
Bruno Oliveira
ab331c906e
Suppress errors while removing tmpdir's lock files
...
Fix #5456
2020-06-11 18:59:51 -03:00
Gleb Nikonorov
95cb7fb676
review feedback
2020-06-10 00:44:22 -04:00
Bruno Oliveira
c229d6f46f
Fix mypy checks
2020-06-09 14:48:49 -03:00
Ran Benita
09988f3ed1
Update testing/test_assertion.py
2020-06-09 14:39:40 -03:00
ibriquem
e2e7f15b71
Make dataclasses/attrs comparison recursive, fixes #4675
2020-06-09 14:39:40 -03:00
piotrhm
df562533ff
Fixed test
2020-06-08 22:26:14 -03:00
piotrhm
2be1c61eb3
Fixed linting 2
2020-06-08 22:26:14 -03:00
piotrhm
5e0e12d69b
Fixed linting
2020-06-08 22:26:14 -03:00
piotrhm
51fb11c1d1
Added tests
2020-06-08 22:26:14 -03:00
Bruno Oliveira
fcbaab8b0b
Allow tests to override "global" `log_level` (rebased) ( #7340 )
...
Co-authored-by: Ruaridh Williamson <ruaridh.williamson@flexciton.com>
2020-06-08 22:05:46 -03:00
Prashant Anand
e78207c936
7119: data loss with mistyped --basetemp ( #7170 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-08 21:54:22 -03:00
Fabio Zadrozny
322190fd84
Fix issue where working dir becomes wrong on subst drive on Windows. Fixes #5965 ( #6523 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-06-08 10:56:40 -03:00
Bruno Oliveira
c17d50829f
Add pyproject.toml support ( #7247 )
2020-06-08 10:03:10 -03:00
Gleb Nikonorov
f1746c50ea
Merge remote-tracking branch 'origin/master' into issue_7305
2020-06-06 12:37:56 -04:00
Gleb Nikonorov
2a3c21645e
Commit solution thus far, needs to be polished up pre PR
2020-06-06 02:38:18 -04:00
Ran Benita
1deaa74345
mark/expression: prevent creation of illegal Python identifiers
...
This is rejected by Python DEBUG builds, as well as regular builds in
future versions.
2020-06-05 15:57:48 +03:00
Ran Benita
54ad048be7
Enable check_untyped_defs mypy option for testing/ too
2020-06-05 11:34:20 +03:00