I love assert

Ethan Furman ethan at stoneleaf.us
Wed Nov 12 02:24:27 CET 2014


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 at antonia-HP-2133 /tmp $ python -O test.py
> Ran 2 tests in 0.015s
> OK
>
> antonia at antonia-HP-2133 /tmp $ python -O -m nose test.py
> Ran 2 tests in 0.003s
> OK
>
> antonia at antonia-HP-2133 /tmp $ python test.py
> Ran 2 tests in 0.044s
> FAILED (failures=2)
>
> antonia at antonia-HP-2133 /tmp $ python -m nose test.py
> Ran 2 tests in 0.044s
> FAILED (failures=2)
>
> antonia at 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 at media:~/source$ python3.4 test.py
Ran 1 test in 0.001s
FAILED (failures=1)

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


I'll stick with unittest.

--
~Ethan~



More information about the Python-list mailing list