Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80582 > unrolled thread

Re: I love assert

Started byEthan Furman <ethan@stoneleaf.us>
First post2014-11-11 17:24 -0800
Last post2014-11-11 17:24 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: I love assert Ethan Furman <ethan@stoneleaf.us> - 2014-11-11 17:24 -0800

#80582 — Re: I love assert

FromEthan Furman <ethan@stoneleaf.us>
Date2014-11-11 17:24 -0800
SubjectRe: I love assert
Message-ID<mailman.15705.1415755472.18130.python-list@python.org>
On 11/11/2014 01:46 PM, Albert-Jan Roskam wrote:
> Ethan Furman wrote:
>>
>> 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 $ 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
> Ran 2 tests in 0.044s
> FAILED (failures=2)
>
> antonia@antonia-HP-2133 /tmp $ python -m nose test.py
> Ran 2 tests in 0.044s
> FAILED (failures=2)
>
> antonia@antonia-HP-2133 /tmp $ nosetests -O -v test.py
> Usage: nosetests [options]
>
> nosetests: error: no such option: -O   # phweeew

In other words, nose the module doesn't handle optimized mode, and apparently nosetests cannot run in optimized mode.

On the other hand, unittest:
--------------------------------------
from unittest import TestCase, main

class TestTest(TestCase):
     def test_optimized(self):
         self.assertTrue(1 == 2)

if __name__ == '__main__':
     main()
--------------------------------------

ethan@media:~/source$ python3.4 test.py
Ran 1 test in 0.001s
FAILED (failures=1)

ethan@media:~/source$ python3.4 -O test.py
Ran 1 test in 0.001s
FAILED (failures=1)


I'll stick with unittest.

--
~Ethan~

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web