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
Ran Benita
2833884688
Type annotate pytest.fixture and more improvements to _pytest.fixtures
2020-06-05 11:34:20 +03:00
Ran Benita
90e58f8961
Type annotate some parts related to runner & reports
2020-06-05 11:34:20 +03:00
Ran Benita
d95132178c
Type annotate _pytest.assertion
2020-06-05 11:34:19 +03:00
Ran Benita
247c4c0482
Type annotate some more hooks & impls
2020-06-05 11:34:19 +03:00
Ran Benita
ef34729541
Type annotate fixtures.py & related
2020-06-05 11:34:19 +03:00
Ran Benita
ff8b7884e8
Type annotate ParameterSet
2020-06-05 11:34:19 +03:00
Ran Benita
2e219ad4f3
testing: change a test to not use deprecated pluggy __multicall__ protocol
...
It is slated to be removed in pluggy 1.0.
2020-06-03 21:51:55 +03:00
Bruno Oliveira
61a6ac9705
Merge pull request #7242 from nicoddemus/fix-flaky-test
...
Introduce _pytest.timing as a way to control timing during internal tests
2020-06-02 20:25:02 -03:00
Bruno Oliveira
8ac18bbecb
Show invalid ini keys sorted
...
Otherwise this relies on the dictionary order of `config.inicfg`, which
is insertion order in py36+ but "random" order in py35.
2020-06-02 16:01:47 -03:00
Bruno Oliveira
7a8b8a5c9f
Merge branch 'master' into fix-flaky-test
2020-06-02 11:33:15 -03:00
Ronny Pfannschmidt
8faf1e8eca
Merge pull request #7286 from gnikonorov/issue_6856
...
Output a warning to stderr when an invalid key is read from an INI config file
2020-06-02 15:47:02 +02:00
Tor Colvin
fe64093411
Fix removal of very long paths on Windows ( #6755 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-06-02 08:56:33 -03:00
Bruno Oliveira
70b5bdf4ba
Merge pull request #7264 from bluetech/wcwidth
...
Improve our own wcwidth implementation and remove dependency on wcwidth package
2020-05-31 12:37:58 -03:00
Ronny Pfannschmidt
c16ede5ce6
Merge pull request #7255 from gnikonorov/issue_4049
...
Add new hook pytest_warning_recorded
2020-05-31 12:47:46 +02:00
Gleb Nikonorov
db203afba3
Add in --strict-config flag to force warnings to errors
2020-05-31 02:45:40 -04:00
Gleb Nikonorov
8f2c2a5dd9
Add test case for invalid ini key in different section header
2020-05-31 00:49:21 -04:00
Gleb Nikonorov
eef4f87e7b
Output a warning to stderr when an invalid key is read from an INI config file
2020-05-30 20:36:02 -04:00
Bruno Oliveira
b98aa195e0
Add test and changelog for #6428
2020-05-30 20:02:47 -03:00
Bruno Oliveira
56bf819c2f
Do not call TestCase.tearDown for skipped tests ( #7236 )
...
Fix #7215
2020-05-30 14:33:22 -03:00
Katarzyna Król
94c7b8b47c
Issue 1316 - longrepr is a string when pytrace=False ( #7100 )
2020-05-30 14:10:58 +03:00
Gleb Nikonorov
2af0d1e221
remove a stray comma in a test tuple
2020-05-28 00:02:28 -04:00
Gleb Nikonorov
14de08011b
fix the unit tests, add the proper deprecation warning, and add in a changelog entry
2020-05-27 23:03:07 -04:00
Anthony Sottile
b3db440d4c
Merge pull request #7257 from DahlitzFlorian/fix-issue-6956
...
Prevent pytest from printing ConftestImportFailure traceback
2020-05-27 13:49:43 -07:00
Ran Benita
f93e021bc8
capture: remove some unclear parametrization from a test
...
The two cases end up doing the same (the tmpfile fixture isn't used
except being truthy).
2020-05-27 15:27:16 +03:00
Ran Benita
a35800c2e1
capture: formalize and check allowed state transition in capture classes
...
There are state transitions start/done/suspend/resume and two additional
operations snap/writeorg.
Previously it was not well defined in what order they can be called, and
which operations are idempotent.
Formalize this and enforce using assert checks with informative error
messages if they fail (rather than random AttributeErrors).
2020-05-27 15:27:15 +03:00
Florian Dahlitz
5b9924e144
Fix py35 CI run
2020-05-27 09:27:13 +02:00
Gleb Nikonorov
d742b386c3
provide missing location parameter, and add type annotations to the hookspec
2020-05-27 00:53:31 -04:00
Ran Benita
aca534c67d
Improve our own wcwidth implementation and remove dependency on wcwidth package
...
`TerminalWriter`, imported recently from `py`, contains its own
incomplete wcwidth (`char_with`/`get_line_width`) implementation. The
`TerminalReporter` also needs this, but uses the external `wcwidth`
package.
This commit brings the `TerminalWriter` implementation up-to-par with
`wcwidth`, moves to implementation to a new file `_pytest._io.wcwidth`
which is used everywhere, and removes the dependency.
The differences compared to the `wcwidth` package are:
- Normalizes the string before counting.
- Uses Python's `unicodedata` instead of vendored Unicode tables. This
means the data corresponds to the Python's version Unicode version
instead of the `wcwidth`'s package version.
- Apply some optimizations.
2020-05-26 17:14:01 +03:00
Florian Dahlitz
95bd232e57
Apply suggestions from @bluetech
2020-05-26 10:31:53 +02:00
Ran Benita
ea3f44894f
capture: replace TeeSysCapture with SysCapture(tee=True)
...
This is more straightforward and does not require duplicating the
initialization logic.
2020-05-26 00:25:49 +03:00
Ran Benita
491239d9b2
capture: remove some indirection in MultiCapture
...
Removing this indirection enables some further clean ups.
2020-05-26 00:25:49 +03:00
Florian Dahlitz
6546d1f725
Prevent pytest from printing ConftestImportFailure traceback
2020-05-25 13:57:03 +02:00
Gleb Nikonorov
088d400b2d
rename pytest_warning_record -> pytest_warning_recorded
2020-05-24 20:43:23 -04:00
Gleb Nikonorov
9ee6550181
Add in a new hook pytest_warning_recorded for warning capture
...
communication
2020-05-24 19:05:24 -04:00
Anthony Sottile
45f53266e6
Merge pull request #7244 from DahlitzFlorian/fix-issue-7150
...
Prevent hiding underlying exception when ConfTestImportFailure is raised
2020-05-23 12:09:42 -07:00
Florian Dahlitz
35e6dd0117
Add test for exposure of underlying exception
2020-05-23 18:19:33 +02:00
Bruno Oliveira
1780924b27
Introduce _pytest.timing as a way to control timing during tests
...
_pytest.timing is an indirection to 'time' functions, which pytest production
code should use instead of 'time' directly.
'mock_timing' is a new fixture which then mocks those functions, allowing us
to write time-reliable tests which run instantly and are not flaky.
This was triggered by recent flaky junitxml tests on Windows related to timing
issues.
2020-05-23 11:50:33 -03:00
Claire Cecil
79701c65ed
Added support for less verbose version information ( #7169 )
2020-05-23 11:27:58 -03:00
Ran Benita
4a1557fa0e
Merge pull request #7091 from bluetech/capture-invalid-fd
...
Perform FD capturing even if the FD is invalid
2020-05-22 14:36:49 +03:00
Ran Benita
919ac2239d
Merge pull request #7231 from bluetech/logging-error
...
logging: propagate errors during log message emits
2020-05-22 14:27:26 +03:00
Ran Benita
eaeafd7c30
Perform FD capturing even if the FD is invalid
...
The `FDCapture`/`FDCaptureBinary` classes, used by `capfd`/`capfdbinary`
fixtures and the `--capture=fd` option (set by default), redirect FDs
1/2 (stdout/stderr) to a temporary file. To do this, they need to save
the old file by duplicating the FD before redirecting it, to be restored
once finished.
Previously, if this duplicating (`os.dup()`) failed, most likely due to
that FD being invalid, the FD redirection would silently not be done. The
FD capturing also performs python-level redirection (monkeypatching
`sys.stdout`/`sys.stderr`) which would still be done, but direct writes
to the FDs would fail.
This is not great. If pytest is run with `--capture=fd`, or a test is
using `capfd`, it expects writes to the FD to work and be captured,
regardless of external circumstances.
So, instead of disabling FD capturing, keep the redirection to a
temporary file, just don't restore it after closing, because there is
nothing to restore to.
2020-05-20 19:32:37 +03:00
Bruno Oliveira
0a03217903
Merge pull request #7046 from blueyed/k-skip-session-upstream
2020-05-19 20:09:36 -03:00
Daniel Hahler
35d136161a
add test
...
Fixes the test to not match e.g. hypothesis (ref: bdde2ac28).
Conflicts:
testing/test_helpconfig.py
2020-05-19 19:34:08 -03:00
Bruno Oliveira
55099e57c3
Add requested comment as per review
2020-05-19 19:20:41 -03:00
Daniel Hahler
b98a182aa1
(no) coverage
2020-05-19 19:20:41 -03:00
Daniel Hahler
61180eec93
Test behavior of Source with regard to decorators
...
Unlinke `inspect.getsource` it does not unwrap functions.
2020-05-19 19:20:41 -03:00
Bruno Oliveira
5a6296a2d7
Merge pull request #7226 from nicoddemus/remove-function-args
2020-05-19 18:53:23 -03:00
Ran Benita
b13fcb23d7
logging: propagate errors during log message emits
...
Currently, a bad logging call, e.g.
logger.info('oops', 'first', 2)
triggers the default logging handling, which is printing an error to
stderr but otherwise continuing.
For regular programs this behavior makes sense, a bad log message
shouldn't take down the program. But during tests, it is better not to
skip over such mistakes, but propagate them to the user.
2020-05-19 11:16:39 +03:00
Ran Benita
85a06cfafb
Merge pull request #7227 from bluetech/logging-reuse-handler
...
logging: reuse LoggingCaptureHandler instance since it's expensive to create
2020-05-18 23:16:51 +03:00
Bruno Oliveira
ad3169428b
Remove unused Function.__init__ 'args' parameter
2020-05-18 14:30:48 -03:00
Daniel Hahler
8b9b81c3c0
Function: use `originalname` in `_getobj` and make it default to `name` ( #7035 )
2020-05-18 14:08:47 -03:00
Ran Benita
d2d11a8bdc
logging: reuse LoggingCaptureHandler instance since it's expensive to create
...
Previously, a LoggingCaptureHandler was instantiated for each test's
setup/call/teardown which turns out to be expensive.
Instead, only keep one instance and reset it between runs.
2020-05-18 11:27:50 +03:00
Anthony Sottile
9310d67773
Merge pull request #7003 from blueyed/tests-reload-upstream
...
tests: revisit tests for removed load_module
2020-05-17 14:36:13 -07:00
Daniel Hahler
18bc706fdc
tests: revisit tests for removed load_module
...
The tests came via c629f6b18
and c61ff31ffa
.
The fixes from there are kind of obsoleted by 4cd08f9
(moving to importlib),
but it makes sense to keep them as integration tests in general.
2020-05-17 14:16:43 -07:00
Ran Benita
e27228a4e4
Merge pull request #7224 from bluetech/logging-simplifications
...
logging: some simplifications/cleanups
2020-05-18 00:15:59 +03:00
Ran Benita
3f8200676f
logging: remove deprecated --no-print-logs option/ini
...
This option was deprecated in 5.4.0 and was marked for removal in 6.0.0.
2020-05-17 21:41:38 +03:00
Ran Benita
ac6c02f1e2
logging: use item's store for private attributes
...
This makes things type-safe and properly private.
2020-05-17 20:42:05 +03:00
Bruno Oliveira
9e1e7fcabe
Use a nice string repr for ConftestImportFailure
...
The default message is often hard to read:
E _pytest.config.ConftestImportFailure: (local('D:\\projects\\pytest\\.tmp\\root\\foo\\conftest.py'), (<class 'RuntimeError'>, RuntimeError('some error',), <traceback object at 0x000001CCC3E39348>))
Using a shorter message is better:
E _pytest.config.ConftestImportFailure: RuntimeError: some error (from D:\projects\pytest\.tmp\root\foo\conftest.py)
And we don't really lose any information due to exception chaining.
2020-05-17 11:26:30 -03:00
Bruno Oliveira
c5b367b4f4
Package.name now contains only basname of the package
...
Previously it contained the entire path, which made '-k' match
against any name in the full path of the package.
Fix #7040
2020-05-16 15:04:07 -03:00
Bruno Oliveira
f506682abe
Merge pull request #6919 from nicoddemus/backport-6914
2020-05-16 12:42:15 -03:00
Daniel Hahler
d530d70128
Fix regressions with `--lf` plugin
...
Only filter with known failures, and explicitly keep paths of passed
arguments.
This also displays the "run-last-failure" status before collected files,
and does not update the cache with "--collect-only".
Fixes https://github.com/pytest-dev/pytest/issues/6968 .
2020-05-15 18:35:38 -03:00