Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101461
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Question on pytest example code |
| Date | 2016-01-10 23:00 -0500 |
| Message-ID | <mailman.4.1452484871.13488.python-list@python.org> (permalink) |
| References | <1c9f8fb6-b903-4204-86f6-9d8c81e69acd@googlegroups.com> |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Question on pytest example code Robert <rxjwg98@gmail.com> - 2016-01-10 11:38 -0800 Re: Question on pytest example code Terry Reedy <tjreedy@udel.edu> - 2016-01-10 23:00 -0500
csiph-web