Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52335
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <nedbat@gmail.com> |
| 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; 'class,': 0.07; 'debugging': 0.07; 'test,': 0.07; 'broke': 0.09; 'executes': 0.09; 'feature.': 0.09; 'subject:test': 0.09; 'tests,': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'times,': 0.14; '"calling': 0.16; 'constructs': 0.16; 'drag': 0.16; 'handler,': 0.16; 'handler.': 0.16; 'logger': 0.16; 'once.': 0.16; 'right:': 0.16; 'roy': 0.16; 'runs,': 0.16; 'statement.': 0.16; 'stuff.': 0.16; 'subject:run': 0.16; 'two.': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'module': 0.19; 'written,': 0.19; 'appears': 0.22; 'example': 0.22; 'tests': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'adds': 0.24; 'library,': 0.24; 'module,': 0.24; 'test.': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'holds': 0.26; 'logging': 0.26; 'header:In-Reply-To:1': 0.27; 'appear': 0.29; 'feature': 0.29; 'code': 0.31; 'getting': 0.31; 'lines': 0.31; 'josh': 0.31; 'seemingly': 0.31; 'run': 0.32; 'another': 0.32; 'cases': 0.33; 'minimal': 0.33; 'plain': 0.33; 'maybe': 0.34; 'problem': 0.35; 'problem.': 0.35; 'objects': 0.35; 'one,': 0.35; 'test': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'example,': 0.37; 'turn': 0.37; 'two': 0.37; 'needed': 0.38; 'pm,': 0.38; 'sure': 0.39; 'logged': 0.60; 'first': 0.61; "you've": 0.63; 'decided': 0.64; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'incorporate': 0.68; 'smith': 0.68; 'special': 0.74; 'article': 0.77; 'demonstrates': 0.84; 'subject:times': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=KqRApD28/EWhrqJ5zmIMBH0XCR+pFuFu/8lfmDAIX7k=; b=ThFRIn1IyetmLQ9SKcGxG6tLX1Z8XcP/2CtaEeCylXQaBjRQhwVEthY6UITXS4b1wy vHvu9Rw5R4Onv3/Ci2shZfRtO/wAw8e+WnvMQeQfNpfiws8ALErGwo7n4yfP5W90EknT TZGDf5VYDPvkKrpxRcgtPoZH4QiczyiGCF9wVl27p6SuGOaxwuH/xbGxhMWZXOMwUj+3 3JfC5EJx9pSZ7O+9iJTvJjQyA+kO4WOEDyuFb1c6zfKm1ssgpN0MsfVZDxripAZNsPnQ RhpFH0Dq7CyIydvsvOijxcQ4vtJHsHB4JXBI+CstpskLt2UkC/qWojr2wZkT1zJoQhSm RY3Q== |
| X-Received | by 10.220.43.19 with SMTP id u19mr3488534vce.3.1376175177324; Sat, 10 Aug 2013 15:52:57 -0700 (PDT) |
| Sender | Ned Batchelder <nedbat@gmail.com> |
| Date | Sat, 10 Aug 2013 18:52:53 -0400 |
| From | Ned Batchelder <ned@nedbatchelder.com> |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 |
| MIME-Version | 1.0 |
| To | Joshua.R.English@gmail.com |
| Subject | Re: How many times does unittest run each test? |
| References | <f7b24010-f3f4-4e86-b6c4-9ddb503d0412@googlegroups.com> <roy-FE5D5B.16404310082013@news.panix.com> |
| In-Reply-To | <roy-FE5D5B.16404310082013@news.panix.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Mailman-Approved-At | Sun, 11 Aug 2013 02:03:27 +0200 |
| Cc | python-list@python.org |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.445.1376179409.1251.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1376179409 news.xs4all.nl 16012 [2001:888:2000:d::a6]:41935 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:52335 |
Show key headers only | View raw
On 8/10/13 4:40 PM, Roy Smith wrote: > In article <f7b24010-f3f4-4e86-b6c4-9ddb503d0412@googlegroups.com>, > Josh English <Joshua.R.English@gmail.com> wrote: > >> I am working on a library, and adding one feature broke a seemingly unrelated >> feature. As I already had Test Cases written, I decided to try to incorporate >> the logging module into my class, and turn on debugging at the logger before >> the newly-broken test. >> >> Here is an example script: > [followed by 60 lines of code] > > The first thing to do is get this down to some minimal amount of code > that demonstrates the problem. > > For example, you drag in the logging module, and do some semi-complex > configuration. Are you SURE your tests are getting run multiple times, > or maybe it's just that they're getting LOGGED multiple times. Tear out > all the logging stuff. Just use a plain print statement. Roy is right: the problem isn't the tests, it's the logging. You are calling .addHandler in the SimpleChecker.__init__, then you are constructing two SimpleCheckers, each of which adds a handler. In the LoaderTC test, you've only constructed one, adding only one handler, so the "calling q" line only appears once. Then the NameSpaceTC tests runs, constructs another SimplerChecker, which adds another handler, so now there are two. That's why the "calling a" and "calling f" lines appear twice. Move your logging configuration to a place that executes only once. Also, btw, you don't need the "del self.checker" in your tearDown methods: the test object is destroyed after each test, so any objects it holds will be released after each test with no special action needed on your part. --Ned.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How many times does unittest run each test? Josh English <Joshua.R.English@gmail.com> - 2013-08-10 13:00 -0700
Re: How many times does unittest run each test? Roy Smith <roy@panix.com> - 2013-08-10 16:40 -0400
Re: How many times does unittest run each test? Josh English <Joshua.R.English@gmail.com> - 2013-08-10 15:53 -0700
Re: How many times does unittest run each test? Roy Smith <roy@panix.com> - 2013-08-10 19:14 -0400
Re: How many times does unittest run each test? Chris Angelico <rosuav@gmail.com> - 2013-08-11 00:21 +0100
Re: How many times does unittest run each test? Josh English <Joshua.R.English@gmail.com> - 2013-08-10 17:52 -0700
Re: How many times does unittest run each test? Chris Angelico <rosuav@gmail.com> - 2013-08-11 02:10 +0100
Re: How many times does unittest run each test? Josh English <Joshua.R.English@gmail.com> - 2013-08-10 17:47 -0700
Re: How many times does unittest run each test? Josh English <joshua.r.english@gmail.com> - 2013-08-10 15:58 -0700
Re: How many times does unittest run each test? Ned Batchelder <ned@nedbatchelder.com> - 2013-08-10 18:52 -0400
csiph-web