Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80569
| Date | 2014-11-11 21:46 +0000 |
|---|---|
| From | Albert-Jan Roskam <fomcl@yahoo.com> |
| References | <54627C8A.6080003@stoneleaf.us> |
| Subject | Re: I love assert |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15694.1415742730.18130.python-list@python.org> (permalink) |
----- Original Message ----- > From: Ethan Furman <ethan@stoneleaf.us> > To: Albert-Jan Roskam <fomcl@yahoo.com> > Cc: "python-list@python.org" <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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: I love assert Albert-Jan Roskam <fomcl@yahoo.com> - 2014-11-11 21:46 +0000
csiph-web