Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #110263
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ben Finney <ben+python@benfinney.id.au> |
| Newsgroups | comp.lang.python |
| Subject | Re: Marking a subtest as an expected failure |
| Date | Wed, 22 Jun 2016 05:03:21 +1000 |
| Lines | 43 |
| Message-ID | <mailman.18.1466535815.11516.python-list@python.org> (permalink) |
| References | <5768faaa$0$2846$c3e8da3$76491128@news.astraweb.com> <858txyxt3a.fsf@benfinney.id.au> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de I3lc4jwY06xbvB0qTk4IXQaUKb7KTDYYcQzzHkgvrYuA== |
| Cancel-Lock | sha1:yLiyA0MTPXva+Z/ULweWT1IgfaQ= |
| 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.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'api.': 0.04; 'context': 0.05; 'nasty': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'undocumented': 0.09; 'bug': 0.10; 'def': 0.13; '8bit%:32': 0.16; 'attribute::': 0.16; 'failure?': 0.16; 'justified': 0.16; 'magic': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'attribute': 0.18; 'module,': 0.18; 'hack': 0.18; 'cloud': 0.20; 'decorator': 0.22; 'mixed': 0.22; 'decide': 0.23; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'clever': 0.29; 'skip:s 30': 0.31; 'computing': 0.32; 'though,': 0.32; 'useful': 0.33; "d'aprano": 0.33; 'interaction': 0.33; 'steven': 0.33; 'expected': 0.35; 'according': 0.36; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'setting': 0.37; 'received:org': 0.37; 'end': 0.39; 'test': 0.39; 'does': 0.39; 'easily': 0.39; 'to:addr:python.org': 0.40; 'mark': 0.40; 'our': 0.64; 'skip:\xe2 10': 0.70; '\xe2\x80\x93': 0.72; 'sole': 0.76; '_o__)': 0.84; 'received:125': 0.84; '\xe2\x80\xa6': 0.84; 'skip:\xe2 30': 0.91; 'trouble.': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | jigong.madmonks.org |
| X-Public-Key-ID | 0xAC128405 |
| X-Public-Key-Fingerprint | 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 |
| X-Public-Key-URL | http://www.benfinney.id.au/contact/bfinney-pubkey.asc |
| X-Post-From | Ben Finney <bignose+hates-spam@benfinney.id.au> |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| 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> |
| X-Mailman-Original-Message-ID | <858txyxt3a.fsf@benfinney.id.au> |
| X-Mailman-Original-References | <5768faaa$0$2846$c3e8da3$76491128@news.astraweb.com> |
| Xref | csiph.com comp.lang.python:110263 |
Show key headers only | View raw
Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes:
> def test_spam(self):
> for i in range(100):
> for j in range(100):
> with self.subtest(i=i, j=j):
> if (i, j) != (97, 83):
> self.assertEqual(spam(i, j), 999)
>
>
> but is there a nicer way to mark a specific subtest as an expected
> failure?
Expected failures and subtests are apparently not easily mixed using the
current API.
Digging into the ‘unittest.case’ module, the ‘expectedFailure’ decorator
does its job by setting the test case's ‘__unittest_expecting_failure__’
attribute to ‘True’.
Perhaps you can get the subtest object from the context manager, and
decide to set that magic attribute::
# …
with self.subtest(i=i, j=j) as subtest:
if (i, j) == (97, 83):
# The inhabitants of (97, 83) have always been trouble.
subtest.__unittest_expecting_failure__ = True
self.assertEqual(spam(i, j), 999)
That attribute is undocumented though, so I don't know whether to
consider that a nasty hack or a clever one. (Nor do I know whether it
works as I expect.)
You would be justified to report a bug that this interaction of useful
features should really be easier to access.
--
\ “Try adding “as long as you don't breach the terms of service – |
`\ according to our sole judgement” to the end of any cloud |
_o__) computing pitch.” —Simon Phipps, 2010-12-11 |
Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Marking a subtest as an expected failure Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-21 18:28 +1000 Re: Marking a subtest as an expected failure Ben Finney <ben+python@benfinney.id.au> - 2016-06-22 05:03 +1000
csiph-web