Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101461
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Terry Reedy <tjreedy@udel.edu> |
| Newsgroups | comp.lang.python |
| Subject | Re: Question on pytest example code |
| Date | Sun, 10 Jan 2016 23:00:47 -0500 |
| Lines | 36 |
| Message-ID | <mailman.4.1452484871.13488.python-list@python.org> (permalink) |
| References | <1c9f8fb6-b903-4204-86f6-9d8c81e69acd@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de KJM5hvJ3nu8cgJf0uuG5NgLJvpRHNhsWWu8enWS9R9eQ== |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'context': 0.05; 'subject:Question': 0.05; 'raises': 0.07; 'report.': 0.07; 'subject:code': 0.07; 'unittest': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'snippet': 0.09; 'jan': 0.11; 'exception': 0.13; 'def': 0.13; 'presume': 0.16; 'pytest': 0.16; 'pytest,': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'wrote:': 0.16; 'passes': 0.18; 'tests': 0.18; 'latter': 0.22; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'not.': 0.27; 'package.': 0.27; 'function': 0.28; "skip:' 10": 0.28; 'raise': 0.29; 'code': 0.30; 'checks': 0.30; "skip:' 20": 0.34; 'i.e.': 0.35; 'robert': 0.35; 'there': 0.36; 'received:71': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'received:org': 0.37; 'missing': 0.37; 'release': 0.37; 'version': 0.38; 'skip:p 20': 0.38; 'hi,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'more': 0.63; 'received:fios.verizon.net': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | pool-71-185-227-36.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 |
| In-Reply-To | <1c9f8fb6-b903-4204-86f6-9d8c81e69acd@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:101461 |
Show key headers only | View raw
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