Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'error:': 0.07; 'tool,': 0.07; '"__main__":': 0.09; '__name__': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'def': 0.12; 'skip:= 70': 0.12; '(same': 0.16; 'intended.': 0.16; 'nose': 0.16; 'option:': 0.16; 'previous)': 0.16; 'wrote:': 0.18; 'code.': 0.18; '>>>': 0.22; 'import': 0.22; 'tests': 0.22; 'cc:addr:python.org': 0.22; 'certainly': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'assert': 0.31; 'file': 0.32; 'probably': 0.32; 'run': 0.32; '(most': 0.33; '-----': 0.33; 'but': 0.35; 'skip:" 50': 0.36; 'easily': 0.37; 'pm,': 0.38; 'recent': 0.39; 'subject:': 0.39; 'read': 0.60; 'received:98.137': 0.60; 're:': 0.63; 'such': 0.63; 'love': 0.65; 'specialized': 0.65; 'header:Reply-To:1': 0.67; 'email addr:python.org"': 0.68; 'optimized': 0.68; 'received:gq1.yahoo.com': 0.68; 'received:mail.gq1.yahoo.com': 0.68; 'received:98.136': 0.69; 'ethan': 0.84; 'furman': 0.84; 'received:bullet.mail.gq1.yahoo.com': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1415742545; bh=qYVnke1GUm/rERVA5XEchW8XzvAMlGsmE4x6YPEVIfs=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=S+54HZmhHC6EeduZ5uGQuBy6K3jvpwiGNT04/BHG34CoOtqC8ci4NksBn9mDafmNiFRgefYjbGXRXReQfk6IIH3GygLf44lv8ohVgXKX5iBKDkmYugCCVGJha1EMe70kae4ASVqNIVOIeoj8FfN1EoNQuKU0BmUsD4m/235ks80j7fQgVR3P+KkDUH/Bn2HaQbAtmGGA86xXmaCG+jBP+/UQpeinn5rIGRGvO5Ky2iAYYECxzdABw/Ccm3QHfYpcR50SDWikS6AwmW5V+3GzyRLZuergvm9Qve0rX0NSVkQTy0bJJHeNylDZ9TP8nN7MzrPv9IcZgdX/xBcJRzajQQ== DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.com; b=riFVZ8Xx1tg8IA0ai9vQouxBc+jm97bgfYM229gP0Ww70CeS1R41NjjtcYsAz/BEqSCvL8EKAW1dWrfJXiaDDQVSFyFPq7c3kyod8g362Iuk5stLJeWk4upJYwds3lL1HzkHi5WWbCz/YPwoyE0cdugYWTBEZ1tOgjN+VPrxeLTEPkN4dgDr1Uio0aXmbmy+GN7CftIC0Wa9k66IJG+eDbVj/X7Y3Z3kMdHThElNVkn1nTjQjmxoj1Xn8wtDdVcjjgINYq5i0CpWZdIyTelCLNEqMj78sT23tMXUaKmQRBAKi13CoTGkW5y3Nqb5yBLB6SIloXszmKuTujHRGc/SlA==; X-Yahoo-Newman-Property: ymail-4 X-Yahoo-Newman-Id: 859234.70216.bm@omp1008.mail.gq1.yahoo.com X-YMail-OSG: dpQkGlEVM1nRvF6OB0Wq72K_KqWRZj42B6WKrF36tLbwO9KCMfviBAQ3KsoiS6m jTYxM.MfQ3zAyHs4f65GintwLUzXVne_9zRRNjnqLo_McE78iFNX9L_NSxpoJIZwTBSX3aVoy9.S Tp6QenEFwz1XeyKqk6dLdJnhMtT8v73P9f_Pj3ja.gl1axLxYawlW2HiKbDRKbydoe.zuxYACVpJ 8vB_AFLpA.5N5ZetdEastbSkFkwQF6WwyCcwQ2pfZyoHIVtSJN9tajuKBrfghb_obo3_Juo95Xr2 iJCMUJaBP8nwUqZe89w0ooy32hrY_BIb7_mfz8ZDB4Y0PBSF8IZLs_dYlC4Cg_5j_zRVsMHZADfd VSSmy_KYghM.BTrbWxKSc2oUMNrUU9pei6s0j0mAhl_MupEEfDAE0XxFUPvq32oPsmzmI.AOYh2Y IURzqsUQ3DisnBw9KSx2gtEg36UYo.PLoHdu5Fyb_ZSksKPm6udjBqFxXmOCjRi2xH8zOeqZucjb 4GfDYqfUAbmpIUX75zo3lq0f..ZRj1elf3hTUj34u3w6cILYt_a6GrtTt_9XAwv4MQ3kxVTiLZgf h98tcDY8kYwBA Date: Tue, 11 Nov 2014 21:46:04 +0000 (UTC) From: Albert-Jan Roskam To: Ethan Furman In-Reply-To: <54627C8A.6080003@stoneleaf.us> References: <54627C8A.6080003@stoneleaf.us> Subject: Re: I love assert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Albert-Jan Roskam 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: 88 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415742730 news.xs4all.nl 2956 [2001:888:2000:d::a6]:57148 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:80569 ----- Original Message ----- > From: Ethan Furman > To: Albert-Jan Roskam > Cc: "python-list@python.org" > Sent: Tuesday, November 11, 2014 10:15 PM > Subject: Re: I love assert > > On 11/11/2014 01:09 PM, Albert-Jan Roskam wrote: >> Ethan Furman wrote: >>> >>> asserts are a specialized tool, easily abused. Sounds like you are > using them >>> exactly as intended. >> >> Would you say that assert is baaadly abused in nose?*) I never tried it, > but >> probably all tests pass when Python is run with -O or -OO. > > I don't know, haven't used it nor read the code. It would certainly not > be good if it failed in optimized mode. antonia@antonia-HP-2133 /tmp $ cat test.py def test_func_1(): assert 1 == 2 def test_func_2(): x = 1; y = 2 assert x == y if __name__ == "__main__": import nose nose.main() antonia@antonia-HP-2133 /tmp $ python -O test.py .. ---------------------------------------------------------------------- Ran 2 tests in 0.015s OK antonia@antonia-HP-2133 /tmp $ python -O -m nose test.py .. ---------------------------------------------------------------------- Ran 2 tests in 0.003s OK antonia@antonia-HP-2133 /tmp $ python test.py FF ====================================================================== FAIL: test.test_func_1 ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest self.test(*self.arg) File "/tmp/test.py", line 2, in test_func_1 assert 1 == 2 AssertionError ====================================================================== FAIL: test.test_func_2 ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest self.test(*self.arg) File "/tmp/test.py", line 6, in test_func_2 assert x == y AssertionError ---------------------------------------------------------------------- Ran 2 tests in 0.044s FAILED (failures=2) antonia@antonia-HP-2133 /tmp $ python -m nose test.py ... (same as previous) antonia@antonia-HP-2133 /tmp $ nosetests -O -v test.py Usage: nosetests [options] nosetests: error: no such option: -O # phweeew