Merge pull request #1306 from nicoddemus/summary-warnings
pytest warnings emitted during ``pytest_terminal_summary`` are now properly displayed.
This commit is contained in:
		
						commit
						e2603d7050
					
				| 
						 | 
					@ -15,6 +15,10 @@
 | 
				
			||||||
- fix #1292: monkeypatch calls (setattr, setenv, etc.) are now O(1).
 | 
					- fix #1292: monkeypatch calls (setattr, setenv, etc.) are now O(1).
 | 
				
			||||||
  Thanks David R. MacIver for the report and Bruno Oliveira for the PR.
 | 
					  Thanks David R. MacIver for the report and Bruno Oliveira for the PR.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- fix #1305: pytest warnings emitted during ``pytest_terminal_summary`` are now
 | 
				
			||||||
 | 
					  properly displayed.
 | 
				
			||||||
 | 
					  Thanks Ionel Maries Cristian for the report and Bruno Oliveira for the PR.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2.8.5
 | 
					2.8.5
 | 
				
			||||||
-----
 | 
					-----
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -364,10 +364,10 @@ class TerminalReporter:
 | 
				
			||||||
            EXIT_OK, EXIT_TESTSFAILED, EXIT_INTERRUPTED, EXIT_USAGEERROR,
 | 
					            EXIT_OK, EXIT_TESTSFAILED, EXIT_INTERRUPTED, EXIT_USAGEERROR,
 | 
				
			||||||
            EXIT_NOTESTSCOLLECTED)
 | 
					            EXIT_NOTESTSCOLLECTED)
 | 
				
			||||||
        if exitstatus in summary_exit_codes:
 | 
					        if exitstatus in summary_exit_codes:
 | 
				
			||||||
 | 
					            self.config.hook.pytest_terminal_summary(terminalreporter=self)
 | 
				
			||||||
            self.summary_errors()
 | 
					            self.summary_errors()
 | 
				
			||||||
            self.summary_failures()
 | 
					            self.summary_failures()
 | 
				
			||||||
            self.summary_warnings()
 | 
					            self.summary_warnings()
 | 
				
			||||||
            self.config.hook.pytest_terminal_summary(terminalreporter=self)
 | 
					 | 
				
			||||||
        if exitstatus == EXIT_INTERRUPTED:
 | 
					        if exitstatus == EXIT_INTERRUPTED:
 | 
				
			||||||
            self._report_keyboardinterrupt()
 | 
					            self._report_keyboardinterrupt()
 | 
				
			||||||
            del self._keyboardinterrupt_memo
 | 
					            del self._keyboardinterrupt_memo
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -739,6 +739,23 @@ def test_terminal_summary(testdir):
 | 
				
			||||||
        world
 | 
					        world
 | 
				
			||||||
    """)
 | 
					    """)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_terminal_summary_warnings_are_displayed(testdir):
 | 
				
			||||||
 | 
					    """Test that warnings emitted during pytest_terminal_summary are displayed.
 | 
				
			||||||
 | 
					    (#1305).
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    testdir.makeconftest("""
 | 
				
			||||||
 | 
					        def pytest_terminal_summary(terminalreporter):
 | 
				
			||||||
 | 
					            config = terminalreporter.config
 | 
				
			||||||
 | 
					            config.warn('C1', 'internal warning')
 | 
				
			||||||
 | 
					    """)
 | 
				
			||||||
 | 
					    result = testdir.runpytest('-rw')
 | 
				
			||||||
 | 
					    result.stdout.fnmatch_lines([
 | 
				
			||||||
 | 
					        '*C1*internal warning',
 | 
				
			||||||
 | 
					        '*== 1 pytest-warnings in *',
 | 
				
			||||||
 | 
					    ])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@pytest.mark.parametrize("exp_color, exp_line, stats_arg", [
 | 
					@pytest.mark.parametrize("exp_color, exp_line, stats_arg", [
 | 
				
			||||||
    # The method under test only cares about the length of each
 | 
					    # The method under test only cares about the length of each
 | 
				
			||||||
    # dict value, not the actual contents, so tuples of anything
 | 
					    # dict value, not the actual contents, so tuples of anything
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue