[issue2821] unittest.py sys.exit error

2008-05-11 Thread Adam Getchell

New submission from Adam Getchell <[EMAIL PROTECTED]>:

Picking the canonical example of unit test:

import random
import unittest

class TestSequenceFunctions(unittest.TestCase):

def setUp(self):
self.seq = range(10)

def testshuffle(self):
# make sure the shuffled sequence does not lose any elements
random.shuffle(self.seq)
self.seq.sort()
self.assertEqual(self.seq, range(10))

def testchoice(self):
element = random.choice(self.seq)
self.assert_(element in self.seq)

def testsample(self):
self.assertRaises(ValueError, random.sample, self.seq, 20)
for element in random.sample(self.seq, 5):
self.assert_(element in self.seq)

if __name__ == '__main__':
unittest.main()

Gives the following error:

>>> 
...
--
Ran 3 tests in 0.003s

OK
Traceback (most recent call last):
  File "C:\Projects\Python\randomunittest.py", line 25, in 
unittest.main()
  File "C:\Python25\lib\unittest.py", line 768, in __init__
self.runTests()
  File "C:\Python25\lib\unittest.py", line 806, in runTests
sys.exit(not result.wasSuccessful())
SystemExit: False

The error lies in the following code snippet:

def runTests(self):
if self.testRunner is None:
self.testRunner = TextTestRunner(verbosity=self.verbosity)
result = self.testRunner.run(self.test)
sys.exit(not result.wasSuccessful())

--
components: Library (Lib)
files: unittest.py
messages: 66651
nosy: acgetchell
severity: normal
status: open
title: unittest.py sys.exit error
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file10289/unittest.py

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2821>
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2821] unittest.py sys.exit error

2008-05-12 Thread Adam Getchell

Adam Getchell <[EMAIL PROTECTED]> added the comment:

Agreed.

C:\Projects\Python>python randomunittest.py
...
--
Ran 3 tests in 0.003s

OK

C:\Projects\Python>

> -Original Message-
> From: Georg Brandl [mailto:[EMAIL PROTECTED]
> Sent: Monday, May 12, 2008 9:22 AM
> To: Getchell, Adam
> Subject: [issue2821] unittest.py sys.exit error
>
>
> Georg Brandl <[EMAIL PROTECTED]> added the comment:
>
> This is an IDLE problem then.
>
> --
> assignee:  -> kbk
> components: +IDLE -Library (Lib)
> nosy: +kbk
>
> __
> Tracker <[EMAIL PROTECTED]>
> <http://bugs.python.org/issue2821>
> __

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2821>
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com