Merge master into features
This commit is contained in:
		
						commit
						803cc1f294
					
				
							
								
								
									
										1
									
								
								AUTHORS
								
								
								
								
							
							
						
						
									
										1
									
								
								AUTHORS
								
								
								
								
							|  | @ -267,5 +267,6 @@ Wouter van Ackooy | ||||||
| Xixi Zhao | Xixi Zhao | ||||||
| Xuan Luong | Xuan Luong | ||||||
| Xuecong Liao | Xuecong Liao | ||||||
|  | Yoav Caspi | ||||||
| Zac Hatfield-Dodds | Zac Hatfield-Dodds | ||||||
| Zoltán Máté | Zoltán Máté | ||||||
|  |  | ||||||
|  | @ -0,0 +1 @@ | ||||||
|  | Fix crash with ``KeyboardInterrupt`` during ``--setup-show``. | ||||||
|  | @ -678,4 +678,4 @@ Or, if desired, you can ``pip install contextlib2`` and use: | ||||||
| 
 | 
 | ||||||
| .. code-block:: python | .. code-block:: python | ||||||
| 
 | 
 | ||||||
|     from contextlib2 import ExitStack as does_not_raise |     from contextlib2 import nullcontext as does_not_raise | ||||||
|  |  | ||||||
|  | @ -135,7 +135,7 @@ class Cache: | ||||||
|         readme_path.write_text(README_CONTENT) |         readme_path.write_text(README_CONTENT) | ||||||
| 
 | 
 | ||||||
|         gitignore_path = self._cachedir.joinpath(".gitignore") |         gitignore_path = self._cachedir.joinpath(".gitignore") | ||||||
|         msg = "# Created by pytest automatically.\n*" |         msg = "# Created by pytest automatically.\n*\n" | ||||||
|         gitignore_path.write_text(msg, encoding="UTF-8") |         gitignore_path.write_text(msg, encoding="UTF-8") | ||||||
| 
 | 
 | ||||||
|         cachedir_tag_path = self._cachedir.joinpath("CACHEDIR.TAG") |         cachedir_tag_path = self._cachedir.joinpath("CACHEDIR.TAG") | ||||||
|  |  | ||||||
|  | @ -195,7 +195,6 @@ def get_plugin_manager(): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def _prepareconfig(args=None, plugins=None): | def _prepareconfig(args=None, plugins=None): | ||||||
|     warning = None |  | ||||||
|     if args is None: |     if args is None: | ||||||
|         args = sys.argv[1:] |         args = sys.argv[1:] | ||||||
|     elif isinstance(args, py.path.local): |     elif isinstance(args, py.path.local): | ||||||
|  | @ -213,10 +212,6 @@ def _prepareconfig(args=None, plugins=None): | ||||||
|                     pluginmanager.consider_pluginarg(plugin) |                     pluginmanager.consider_pluginarg(plugin) | ||||||
|                 else: |                 else: | ||||||
|                     pluginmanager.register(plugin) |                     pluginmanager.register(plugin) | ||||||
|         if warning: |  | ||||||
|             from _pytest.warnings import _issue_warning_captured |  | ||||||
| 
 |  | ||||||
|             _issue_warning_captured(warning, hook=config.hook, stacklevel=4) |  | ||||||
|         return pluginmanager.hook.pytest_cmdline_parse( |         return pluginmanager.hook.pytest_cmdline_parse( | ||||||
|             pluginmanager=pluginmanager, args=args |             pluginmanager=pluginmanager, args=args | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| import sys |  | ||||||
| 
 |  | ||||||
| import pytest | import pytest | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -51,7 +49,6 @@ def _show_fixture_action(fixturedef, msg): | ||||||
|     capman = config.pluginmanager.getplugin("capturemanager") |     capman = config.pluginmanager.getplugin("capturemanager") | ||||||
|     if capman: |     if capman: | ||||||
|         capman.suspend_global_capture() |         capman.suspend_global_capture() | ||||||
|         out, err = capman.read_global_capture() |  | ||||||
| 
 | 
 | ||||||
|     tw = config.get_terminal_writer() |     tw = config.get_terminal_writer() | ||||||
|     tw.line() |     tw.line() | ||||||
|  | @ -74,8 +71,6 @@ def _show_fixture_action(fixturedef, msg): | ||||||
| 
 | 
 | ||||||
|     if capman: |     if capman: | ||||||
|         capman.resume_global_capture() |         capman.resume_global_capture() | ||||||
|         sys.stdout.write(out) |  | ||||||
|         sys.stderr.write(err) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @pytest.hookimpl(tryfirst=True) | @pytest.hookimpl(tryfirst=True) | ||||||
|  |  | ||||||
|  | @ -1029,7 +1029,7 @@ def test_gitignore(testdir): | ||||||
|     config = testdir.parseconfig() |     config = testdir.parseconfig() | ||||||
|     cache = Cache.for_config(config) |     cache = Cache.for_config(config) | ||||||
|     cache.set("foo", "bar") |     cache.set("foo", "bar") | ||||||
|     msg = "# Created by pytest automatically.\n*" |     msg = "# Created by pytest automatically.\n*\n" | ||||||
|     gitignore_path = cache._cachedir.joinpath(".gitignore") |     gitignore_path = cache._cachedir.joinpath(".gitignore") | ||||||
|     assert gitignore_path.read_text(encoding="UTF-8") == msg |     assert gitignore_path.read_text(encoding="UTF-8") == msg | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,5 @@ | ||||||
| import pytest | import pytest | ||||||
|  | from _pytest.main import ExitCode | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @pytest.fixture(params=["--setup-only", "--setup-plan", "--setup-show"], scope="module") | @pytest.fixture(params=["--setup-only", "--setup-plan", "--setup-show"], scope="module") | ||||||
|  | @ -267,3 +268,27 @@ def test_show_fixtures_and_execute_test(testdir): | ||||||
|     result.stdout.fnmatch_lines( |     result.stdout.fnmatch_lines( | ||||||
|         ["*SETUP    F arg*", "*test_arg (fixtures used: arg)F*", "*TEARDOWN F arg*"] |         ["*SETUP    F arg*", "*test_arg (fixtures used: arg)F*", "*TEARDOWN F arg*"] | ||||||
|     ) |     ) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def test_setup_show_with_KeyboardInterrupt_in_test(testdir): | ||||||
|  |     p = testdir.makepyfile( | ||||||
|  |         """ | ||||||
|  |         import pytest | ||||||
|  |         @pytest.fixture | ||||||
|  |         def arg(): | ||||||
|  |             pass | ||||||
|  |         def test_arg(arg): | ||||||
|  |             raise KeyboardInterrupt() | ||||||
|  |     """ | ||||||
|  |     ) | ||||||
|  |     result = testdir.runpytest("--setup-show", p, no_reraise_ctrlc=True) | ||||||
|  |     result.stdout.fnmatch_lines( | ||||||
|  |         [ | ||||||
|  |             "*SETUP    F arg*", | ||||||
|  |             "*test_arg (fixtures used: arg)*", | ||||||
|  |             "*TEARDOWN F arg*", | ||||||
|  |             "*! KeyboardInterrupt !*", | ||||||
|  |             "*= no tests ran in *", | ||||||
|  |         ] | ||||||
|  |     ) | ||||||
|  |     assert result.ret == ExitCode.INTERRUPTED | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue