Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101447 > unrolled thread
| Started by | Robert <rxjwg98@gmail.com> |
|---|---|
| First post | 2016-01-10 11:38 -0800 |
| Last post | 2016-01-10 23:00 -0500 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
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
| From | Robert <rxjwg98@gmail.com> |
|---|---|
| Date | 2016-01-10 11:38 -0800 |
| Subject | Question on pytest example code |
| Message-ID | <1c9f8fb6-b903-4204-86f6-9d8c81e69acd@googlegroups.com> |
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()?
Is it missing some assert line?
The above code is from page 5 (9 of 93) of 'pytest Documentation'
Release 2.8.2
Thanks,
[toc] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2016-01-10 23:00 -0500 |
| Message-ID | <mailman.4.1452484871.13488.python-list@python.org> |
| In reply to | #101447 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web