On 1/10/2016 2:38 PM, Robert wrote:
Hi,Below is a code snippet from pytest package. It passes pytest, i.e. there is no failure report. # content of test_sysexit.py import pytest def f(): raise SystemExit(1) def test_mytest(): with pytest.raises(SystemExit): f() I see that f() will generate 'SystemExit(1)'. Then what does function test_mytest()?
What does test_mytest do? It tests that f() raises SystemExit.
Is it missing some assert line?
The unittest version of 'pytest.raises' is 'self.assertRaises'. The latter context manager __exit__ method checks that it is passed the exception given to the __enter__ method and fails if not. I presume the pytest version is more or less identical.
The above code is from page 5 (9 of 93) of 'pytest Documentation' Release 2.8.2
-- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
