Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'failing': 0.07; '[],': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'missing)': 0.09; 'wrapped': 0.09; '~ethan~': 0.09; 'wrote': 0.14; 'clues': 0.16; 'err:': 0.16; 'fail,': 0.16; 'issue?': 0.16; 'reedy': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'tests': 0.22; 'header :User-Agent:1': 0.23; 'specify': 0.24; 'why.': 0.24; "i've": 0.25; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'raise': 0.29; 'along': 0.30; 'factor': 0.31; 'writes:': 0.31; 'yes.': 0.31; 'class': 0.32; 'message.': 0.35; 'except': 0.35; 'etc.)': 0.35; 'test': 0.35; 'but': 0.35; 'raising': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'two': 0.37; 'list': 0.37; 'being': 0.38; 'thank': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'john': 0.61; 'received:173': 0.61; 'more': 0.64; 'believe': 0.68; 'ethan': 0.84; 'fails,': 0.84; 'furman': 0.84; 'presumably': 0.84 Date: Wed, 12 Mar 2014 03:03:24 -0700 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: unittest weirdness References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3304.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source-IP: 173.12.184.233 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:35376 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394620172 news.xs4all.nl 2865 [2001:888:2000:d::a6]:59417 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68271 On 03/11/2014 08:36 PM, Terry Reedy wrote: > On 3/11/2014 6:13 PM, John Gordon wrote: >> In Ethan Furman writes: >> >>> if missing: >>> raise ValueError('invoices %r missing from batch' % missing) >> >> It's been a while since I wrote test cases, but I recall using the assert* >> methods (assertEqual, assertTrue, etc.) instead of raising exceptions. >> Perhaps that's the issue? > > Yes. I believe the methods all raise AssertionError on failure, and the test methods are wrapped with try:.. except > AssertionError as err: > > if missing: > raise ValueError('invoices %r missing from batch' % missing) > > should be "assertEqual(missing, [], 'invoices missing from batch')" and if that fails, the non-empty list is printed > along with the message. I've tried it both ways, and both ways my process is being killed, presumably by the O/S. I will say it's an extra motivating factor to have few failing tests -- if more than two of my tests fail, all I see are '.'s, 'E's, and 'F's, with no clues as to which test failed nor why. Thank goodness for '-v' and being able to specify which method of which class to run! -- ~Ethan~