Merge pull request #2184 from eli-b/parseoutcomes-explicit-failure
Fail assert_outcomes() on missing terminal report
This commit is contained in:
		
						commit
						7b4368f3f4
					
				
							
								
								
									
										1
									
								
								AUTHORS
								
								
								
								
							
							
						
						
									
										1
									
								
								AUTHORS
								
								
								
								
							| 
						 | 
					@ -141,3 +141,4 @@ Tyler Goodlet
 | 
				
			||||||
Vasily Kuznetsov
 | 
					Vasily Kuznetsov
 | 
				
			||||||
Wouter van Ackooy
 | 
					Wouter van Ackooy
 | 
				
			||||||
Xuecong Liao
 | 
					Xuecong Liao
 | 
				
			||||||
 | 
					Eli Boyarski
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,11 +18,15 @@
 | 
				
			||||||
  subdirectories with ini configuration files now uses the correct ini file
 | 
					  subdirectories with ini configuration files now uses the correct ini file
 | 
				
			||||||
  (`#2148`_).  Thanks `@pelme`_.
 | 
					  (`#2148`_).  Thanks `@pelme`_.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* Fail ``testdir.runpytest().assert_outcomes()`` explicitly if the pytest
 | 
				
			||||||
 | 
					  terminal output it relies on is missing. Thanks to `@eli-b`_ for the PR.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
*
 | 
					*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. _@lesteve: https://github.com/lesteve
 | 
					.. _@lesteve: https://github.com/lesteve
 | 
				
			||||||
.. _@malinoff: https://github.com/malinoff
 | 
					.. _@malinoff: https://github.com/malinoff
 | 
				
			||||||
.. _@pelme: https://github.com/pelme
 | 
					.. _@pelme: https://github.com/pelme
 | 
				
			||||||
 | 
					.. _@eli-b: https://github.com/eli-b
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. _#2129: https://github.com/pytest-dev/pytest/issues/2129
 | 
					.. _#2129: https://github.com/pytest-dev/pytest/issues/2129
 | 
				
			||||||
.. _#2148: https://github.com/pytest-dev/pytest/issues/2148
 | 
					.. _#2148: https://github.com/pytest-dev/pytest/issues/2148
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -367,6 +367,7 @@ class RunResult:
 | 
				
			||||||
                    for num, cat in outcomes:
 | 
					                    for num, cat in outcomes:
 | 
				
			||||||
                        d[cat] = int(num)
 | 
					                        d[cat] = int(num)
 | 
				
			||||||
                    return d
 | 
					                    return d
 | 
				
			||||||
 | 
					        raise ValueError("Pytest terminal report not found")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def assert_outcomes(self, passed=0, skipped=0, failed=0):
 | 
					    def assert_outcomes(self, passed=0, skipped=0, failed=0):
 | 
				
			||||||
        """ assert that the specified outcomes appear with the respective
 | 
					        """ assert that the specified outcomes appear with the respective
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -124,3 +124,10 @@ def test_inline_run_clean_modules(testdir):
 | 
				
			||||||
    test_mod.write("def test_foo(): assert False")
 | 
					    test_mod.write("def test_foo(): assert False")
 | 
				
			||||||
    result2 = testdir.inline_run(str(test_mod))
 | 
					    result2 = testdir.inline_run(str(test_mod))
 | 
				
			||||||
    assert result2.ret == EXIT_TESTSFAILED
 | 
					    assert result2.ret == EXIT_TESTSFAILED
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_assert_outcomes_after_pytest_erro(testdir):
 | 
				
			||||||
 | 
					    testdir.makepyfile("def test_foo(): assert True")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    result = testdir.runpytest('--unexpected-argument')
 | 
				
			||||||
 | 
					    with pytest.raises(ValueError, message="Pytest terminal report not found"):
 | 
				
			||||||
 | 
					        result.assert_outcomes(passed=0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue