Commit Graph

12386 Commits

Author SHA1 Message Date
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
Gleb Nikonorov d742b386c3 provide missing location parameter, and add type annotations to the hookspec 2020-05-27 00:53:31 -04:00
Gleb Nikonorov 125b663f20 Address all feedback, minus the empty sring v None nodeid which is being discussed 2020-05-25 11:18:24 -04:00
Gleb Nikonorov 088d400b2d rename pytest_warning_record -> pytest_warning_recorded 2020-05-24 20:43:23 -04:00
Gleb Nikonorov b02d087dbd cleanup code pre pr 2020-05-24 20:26:14 -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 c594bbbd19
Merge pull request #7240 from DahlitzFlorian/fix-issue-7233
Add note about --strict and --strict-markers to references
2020-05-23 12:31:27 -07: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
Claire Cecil 79701c65ed
Added support for less verbose version information (#7169) 2020-05-23 11:27:58 -03:00
Simon K 05c22ff823
7154-Improve-testdir-documentation-on-makefiles (#7239) 2020-05-23 11:27:06 -03:00
Ran Benita b38edec60f
Merge pull request #7238 from bluetech/micro-optimizations-1
A few tiny micro-optimizations/simplifications
2020-05-23 12:14:24 +03:00
Florian Dahlitz d0eb86cfa6
Prevent hiding underlying exception when ConfTestImportFailure is raised 2020-05-22 22:58:35 +02:00
Florian Dahlitz 62d3577435
Add note about --strict and --strict-markers to references 2020-05-22 16:33:50 +02: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 f1f9c7792b Import `packaging` package lazily 2020-05-22 14:33:29 +03:00
Ran Benita 796fba6788 terminal: remove redundant write_fspath_result call
This is already done in pytest_runtest_logstart, so the fspath is
already guaranteed to have been printed (for xdist, it is disabled
anyway).

write_fspath_result is mildly expensive so it is worth avoiding calling
it twice.
2020-05-22 14:33:29 +03:00
Ran Benita 139a029b5e terminal: remove a redundant line
`write_fspath_result` already does this split.
2020-05-22 14:33:29 +03:00
Ran Benita 8d841ab0b8 nodes: remove unused argument from FSHookProxy 2020-05-22 14:33:28 +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
Bruno Oliveira c98bc4cd3d
Merge pull request #7234 from mcsitter/master 2020-05-20 17:51:06 -03:00
mcsitter fa6a13a7cc Updated compatible python versions
As indicated on pypi and in the README pytest supports python version 3.8 and 3.9. The documentation should match.
2020-05-20 22:41:52 +02:00
Ran Benita 1af3c115a6
Merge pull request #7200 from bluetech/contributing-backporting
CONTRIBUTING: add section about backporting fixes to patch releases
2020-05-20 20:21:23 +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
Ran Benita b337a9a66d CONTRIBUTING: add section about backporting fixes to patch releases 2020-05-20 19:29:13 +03:00
Bruno Oliveira 0a03217903
Merge pull request #7046 from blueyed/k-skip-session-upstream 2020-05-19 20:09:36 -03:00
Bruno Oliveira 88214310af
Merge pull request #6817 from blueyed/argparsing-_split_lines-upstream 2020-05-19 20:06:51 -03:00
Bruno Oliveira 5a2c69f150 Add CHANGELOG for #6817 2020-05-19 19:35:18 -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
Daniel Hahler 691a7fceea Revisit some help texts with regard to newlines 2020-05-19 19:34:08 -03:00
Daniel Hahler 87423d3cc8 Keep explicit newlines with help texts
This makes a difference for e.g. pytest-xdist:

Before:
```
  --dist=distmode       set mode for distributing tests to exec environments. each: …
                        available environment. loadscope: …
                        grouped by file to any available environment. (default) no: …
```

After:
```
  --dist=distmode       set mode for distributing tests to exec environments.
                        each: send each test to all available environments.
                        load: load balance by sending any pending test to any available environment.
                        …
                        (default) no: run tests inprocess, don't distribute.
```

This might also result in unexpected changes (hard wrapping), when line
endings where used unintentionally, e.g. with:

```
help="""
    some long
    help text
    """
```

But the benefits from that are worth it, and it is easy to fix, as will
be done for the internal `assertmode` option.
2020-05-19 19:34:08 -03:00
Bruno Oliveira d05ef61e95
Merge pull request #6840 from blueyed/test_source_with_decorator 2020-05-19 19:30:23 -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
Ran Benita fe2febfff2
Merge pull request #7019 from bluetech/rm-pyobj_property
Remove pyobj_property helper, inline it instead
2020-05-18 23:13:52 +03:00
Ran Benita 694fdc6554 Remove pyobj_property helper, inline it instead
It doesn't save much code but adds indirection which makes it a bit
harder to follow and to type.
2020-05-18 20:54:11 +03:00
Katrin Leinweber 9bf28853bf
doc: highlight difference between progress percentage & code coverage (#6686) 2020-05-18 20:51:22 +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 f71ec8cc90 logging: order hookimpl's in chronological order
Makes it easier to understand what's going on.
2020-05-17 21:41:38 +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 bd5e3f042d logging: move log_file_handler cleanup from sessionend to unconfigure
It is set-up in configure, so match it.
2020-05-17 21:41:38 +03:00