test_ok2/testing
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
..
code Add requested comment as per review 2020-05-19 19:20:41 -03:00
example_scripts Fix warnings summary 2020-05-05 21:40:34 +03:00
examples pre-commit run fix-encoding-pragma --all-files 2019-06-03 12:08:01 -03:00
freeze Replace a few outdated references to py.test with pytest 2019-10-26 16:28:17 +03:00
io Merge pull request #7135 from pytest-dev/terminalwriter 2020-05-06 18:26:44 -03:00
logging logging: reuse LoggingCaptureHandler instance since it's expensive to create 2020-05-18 11:27:50 +03:00
python Remove unused Function.__init__ 'args' parameter 2020-05-18 14:30:48 -03:00
acceptance_test.py Handle EPIPE/BrokenPipeError in pytest's CLI 2020-05-08 12:51:02 +03:00
conftest.py Assorted improvements following up #6658 2020-02-20 18:51:41 -03:00
deprecated_test.py logging: remove deprecated --no-print-logs option/ini 2020-05-17 21:41:38 +03:00
test_argcomplete.py Change EnvironmentError, IOError to OSError - they are aliases 2020-03-27 18:40:23 +03:00
test_assertion.py Remove some no-longer-needed compat code in test_assertion 2020-04-08 21:35:42 +03:00
test_assertrewrite.py tests: revisit tests for removed load_module 2020-05-17 14:16:43 -07:00
test_cacheprovider.py Fix regressions with `--lf` plugin 2020-05-15 18:35:38 -03:00
test_capture.py Perform FD capturing even if the FD is invalid 2020-05-20 19:32:37 +03:00
test_collection.py Package.name now contains only basname of the package 2020-05-16 15:04:07 -03:00
test_compat.py tests: cover safe_getattr 2020-01-15 11:20:00 +01:00
test_config.py Use a nice string repr for ConftestImportFailure 2020-05-17 11:26:30 -03:00
test_conftest.py Move ExitCode's definition from _pytest.main to _pytest.config 2020-02-10 23:55:06 +02:00
test_debugging.py Merge remote-tracking branch 'upstream/master' into mm 2020-01-22 11:03:45 -03:00
test_doctest.py Fix _is_setup_py for files encoded differently than locale 2020-05-07 13:14:58 -07:00
test_entry_points.py Replace importlib_metadata with importlib.metadata on Python 3.8+ 2019-07-04 15:00:10 +02:00
test_error_diffs.py pre-commit: upgrade flake8 3.7.7 -> 3.8.1 2020-05-12 09:29:40 +03:00
test_faulthandler.py Skip flaky test test_faulthandler.py::test_timeout[True] 2020-04-09 17:23:54 +03:00
test_helpconfig.py add test 2020-05-19 19:34:08 -03:00
test_junitxml.py Remove Python 2 compat code in test_juintxml.py 2020-04-09 17:33:55 +03:00
test_main.py Merge remote-tracking branch 'upstream/master' into mm 2020-02-11 19:22:28 -03:00
test_mark.py Package.name now contains only basname of the package 2020-05-16 15:04:07 -03:00
test_mark_expression.py mark/expression: support compiling once and reusing for multiple evaluations 2020-05-12 12:53:12 +03:00
test_meta.py Fix test_no_warnings to handle e.g. `_pytest.async` (#7044) 2020-04-09 16:56:01 +02:00
test_monkeypatch.py Remove Python 2 compat check in test_monkeypatch.py 2020-04-09 17:11:18 +03:00
test_nodes.py fix #6341 - disallow session/config in Node.from_parent 2020-01-15 13:00:46 +01:00
test_nose.py Node.location: handle str with _node_location_to_relpath 2020-01-23 10:45:31 +01:00
test_parseopt.py Merge remote-tracking branch 'upstream/master' into mm 2020-02-11 19:22:28 -03:00
test_pastebin.py Fix "lexer" being used when uploading to bpaste.net 2019-08-30 15:34:03 -04:00
test_pathlib.py Switch from deprecated imp to importlib 2019-06-24 09:48:38 -07:00
test_pluginmanager.py Move ExitCode's definition from _pytest.main to _pytest.config 2020-02-10 23:55:06 +02:00
test_pytester.py mark: reuse compiled expression for all items in -k/-m 2020-05-12 12:55:37 +03:00
test_recwarn.py Use a hack to make typing of pytest.fail.Exception & co work 2020-02-18 23:17:27 +02:00
test_reports.py Fix tests: use explicit syspathinsert where tests might hang (#7008) 2020-04-04 12:33:15 +02:00
test_resultlog.py Handle unknown stats in pytest_report_teststatus hook 2020-03-12 20:52:22 -03:00
test_runner.py Remove TestExecutionForked - xdist.boxed has gone since long (#7021) 2020-04-07 08:07:20 +02:00
test_runner_xunit.py Fix plurality mismatch for and in pytest terminal summary 2019-10-27 15:16:24 +00:00
test_session.py Simplify test_rootdir_wrong_option_arg (#6812) 2020-02-28 18:38:07 +01:00
test_setuponly.py Better test method name 2020-05-10 16:59:20 +03:00
test_setupplan.py pre-commit: upgrade flake8 3.7.7 -> 3.8.1 2020-05-12 09:29:40 +03:00
test_skipping.py Remove unnecessary file in test. 2020-05-04 00:34:19 +02:00
test_stepwise.py tests: test_xfail_handling: use sys.dont_write_bytecode 2020-01-11 23:05:12 +01:00
test_store.py Add setdefault() method to Store 2020-03-06 11:42:20 +02:00
test_terminal.py Merge pull request #7064 from blueyed/fix-_printcollecteditems-doc-upstream 2020-05-05 21:31:21 +03:00
test_tmpdir.py Cleanup/move imports with tmpdir tests (#7015) 2020-04-04 14:25:34 +02:00
test_unittest.py Fix test_trial_error in test_unittest 2020-05-02 15:26:55 -03:00
test_warning_types.py Make pytest warnings show as from 'pytest' module instead of '_pytest.warning_types' 2019-06-15 11:48:34 -03:00
test_warnings.py Fix warnings summary 2020-05-05 21:40:34 +03:00