Fix test_recwarn in Python 3.6
No longer test for implementation details of recwarn since warnings.catch_warnings has changed significantly in 3.6.
This commit is contained in:
		
							parent
							
								
									22864b75ee
								
							
						
					
					
						commit
						3c07072bfd
					
				|  | @ -8,25 +8,19 @@ from _pytest.recwarn import WarningsRecorder | |||
| def test_recwarn_functional(testdir): | ||||
|     reprec = testdir.inline_runsource(""" | ||||
|         import warnings | ||||
|         oldwarn = warnings.showwarning | ||||
|         def test_method(recwarn): | ||||
|             assert warnings.showwarning != oldwarn | ||||
|             warnings.warn("hello") | ||||
|             warn = recwarn.pop() | ||||
|             assert isinstance(warn.message, UserWarning) | ||||
|         def test_finalized(): | ||||
|             assert warnings.showwarning == oldwarn | ||||
|     """) | ||||
|     res = reprec.countoutcomes() | ||||
|     assert tuple(res) == (2, 0, 0), res | ||||
|     assert tuple(res) == (1, 0, 0), res | ||||
| 
 | ||||
| 
 | ||||
| class TestWarningsRecorderChecker(object): | ||||
|     def test_recording(self, recwarn): | ||||
|         showwarning = py.std.warnings.showwarning | ||||
|     def test_recording(self): | ||||
|         rec = WarningsRecorder() | ||||
|         with rec: | ||||
|             assert py.std.warnings.showwarning != showwarning | ||||
|             assert not rec.list | ||||
|             py.std.warnings.warn_explicit("hello", UserWarning, "xyz", 13) | ||||
|             assert len(rec.list) == 1 | ||||
|  | @ -40,8 +34,6 @@ class TestWarningsRecorderChecker(object): | |||
|             assert l is rec.list | ||||
|             pytest.raises(AssertionError, "rec.pop()") | ||||
| 
 | ||||
|         assert showwarning == py.std.warnings.showwarning | ||||
| 
 | ||||
|     def test_typechecking(self): | ||||
|         from _pytest.recwarn import WarningsChecker | ||||
|         with pytest.raises(TypeError): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue