Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63747

Re: parametized unittest

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
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; 'url:pypi': 0.03; 'output': 0.05; 'over,': 0.07; 'report.': 0.07; '8bit%:30': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'unittest': 0.09; '8bit%:32': 0.16; 'defined,': 0.16; 'distinct': 0.16; 'failure.': 0.16; 'finney': 0.16; 'loop.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; '\xe2\x80\x9cprogram': 0.16; 'library': 0.18; 'trying': 0.19; 'separate': 0.22; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'advise.': 0.24; 'define': 0.26; 'header:X-Complaints-To:1': 0.27; 'testing': 0.29; "i'm": 0.30; 'writes:': 0.31; 'anyone': 0.31; 'allows': 0.31; 'class': 0.32; 'run': 0.32; 'url:python': 0.33; 'cases': 0.33; 'problem': 0.35; 'test': 0.35; 'but': 0.35; 'url:org': 0.36; 'ben': 0.38; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'break': 0.61; 'effective': 0.61; 'first': 0.61; 'show': 0.63; 'skip:\xe2 10': 0.65; 'it!': 0.67; 'enjoy': 0.71
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben+python@benfinney.id.au>
Subject Re: parametized unittest
Date Sun, 12 Jan 2014 15:22:47 +1100
References <c11a3b62-2053-4b6f-afda-d2df305f58e5@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host rasputin.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-gpg.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Cancel-Lock sha1:1nxqiWfRdbY0ag9oR0oiLmoPvIc=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.5354.1389500578.18130.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389500578 news.xs4all.nl 2867 [2001:888:2000:d::a6]:53258
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63747

Show key headers only | View raw


CraftyTech <hmmedina@gmail.com> writes:

> I'm trying parametize my unittest so that I can re-use over and over,
> perhaps in a for loop.

The ‘testscenarios’ <URL:https://pypi.python.org/pypi/testscenarios>
library allows you to define a set of data scenarios on your
FooBarTestCase and have all the test case functions in that class run
for all the scenarios, as distinct test cases.

e.g. a class with 5 scenarios defined, and 3 test case functions, will
run as 15 distinct test cases with separate output in the report.

> The loop will break after the first failure. Anyone have a good
> approach for this? please advise.

Yes, this is exactly the problem addressed by ‘testscenarios’. Enjoy it!

-- 
 \            “Program testing can be a very effective way to show the |
  `\        presence of bugs, but is hopelessly inadequate for showing |
_o__)                              their absence.” —Edsger W. Dijkstra |
Ben Finney

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

parametized unittest CraftyTech <hmmedina@gmail.com> - 2014-01-11 20:00 -0800
  Re: parametized unittest Ben Finney <ben+python@benfinney.id.au> - 2014-01-12 15:22 +1100
  Re: parametized unittest "W. Trevor King" <wking@tremily.us> - 2014-01-11 20:28 -0800
    Re: parametized unittest Roy Smith <roy@panix.com> - 2014-01-11 23:34 -0500
      Re: parametized unittest CraftyTech <hmmedina@gmail.com> - 2014-01-12 08:57 -0800

csiph-web