Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ethan Furman Newsgroups: comp.lang.python Subject: Re: Quote of the day Date: Wed, 18 May 2016 09:05:31 -0700 Lines: 26 Message-ID: References: <573acd5f$0$1603$c3e8da3$5496439d@news.astraweb.com> <87twhxf5nl.fsf@elektro.pacujo.net> <8e92e249-c46e-4b92-a93b-778879461273@googlegroups.com> <573C92CB.9070502@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 98zFLQk6aKX2L1zYDVO93ggNCrEraumjk++gnIwShCNQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'raises': 0.07; 'although,': 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; 'objects.': 0.09; "(it's": 0.16; 'empty.': 0.16; 'ideally,': 0.16; 'passed.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'run.': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'passes': 0.18; 'tests': 0.18; 'am,': 0.23; 'code.': 0.23; 'errors': 0.23; 'passing': 0.23; 'header:In-Reply- To:1': 0.24; 'header:User-Agent:1': 0.26; 'least': 0.27; 'function': 0.28; '~ethan~': 0.29; 'objects': 0.29; "i'm": 0.30; 'that.': 0.30; 'code': 0.30; 'guess': 0.31; 'changed': 0.33; 'add': 0.34; 'could': 0.35; 'besides': 0.35; 'but': 0.36; 'created': 0.36; "wasn't": 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'building': 0.38; 'test': 0.39; 'sure': 0.39; 'does': 0.39; 'subject:the': 0.39; 'build': 0.40; 'to:addr:python.org': 0.40; 'determine': 0.61; 'real': 0.62; 'total': 0.62; 'success,': 0.63; 'thomas': 0.63; 'benefit': 0.66; 'subject:day': 0.67; 'score': 0.76; 'batchelder': 0.84; 'simple:': 0.84; 'subject:Quote': 0.84 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <573C92CB.9070502@stoneleaf.us> X-Mailman-Original-References: <573acd5f$0$1603$c3e8da3$5496439d@news.astraweb.com> <87twhxf5nl.fsf@elektro.pacujo.net> <8e92e249-c46e-4b92-a93b-778879461273@googlegroups.com> Xref: csiph.com comp.lang.python:108767 On 05/18/2016 08:35 AM, Thomas Mlynarczyk wrote: > On 18/05/16 17:21, Ned Batchelder wrote: >> Ideally, an empty test wouldn't be a success, but I'm not sure how >> the test runner could determine that it was empty. I guess it could >> introspect the test function to see if it had any real code in it, >> but I don't know of a test runner that does that. > > Simple: a function which does not produce at least one "failure" or > "pass" does not test anything. No need to introspect the code. Just > check if the total score of failures and passes has changed after the > function was run. Not so simple: I have tests that do nothing besides build objects. If building the objects raises no errors the test passed. Although, for the benefit of empty tests not passing I could add a do-nothing assert: self.assertTrue(created_obj) (it's a do-nothing because if the object wasn't created the test would have already failed). -- ~Ethan~