unittest not being run
John Maclean
jayeola at gmail.com
Mon May 10 08:38:49 EDT 2010
hi,
can some one explain why the __first__ test is not being run?
#!/usr/bin/env python
import unittest # {{{
class T1TestCase(unittest.TestCase):
def setUp(self):
pass # can we use global variables here?
def tearDown(self):
pass # garbage collection
def test_T1(self):
'''this test aint loading'''
self.assertEquals(1, 0)
def test_T2(self): ## test method names begin 'test*'
self.assertEquals((1 + 2), 3)
self.assertEquals(0 + 1, 1)
def test_T3(self):
self.assertEquals((0 * 10), 0)
self.assertEquals((5 * 8), 40)
# the output is better. prints each test and ok or fail
suite = unittest.TestLoader().loadTestsFromTestCase(T1TestCase)
unittest.TextTestRunner(verbosity=2).run(suite) # }}}
''' halp!
the first test ain't loading...
python blaht.py
test_T2 (__main__.T1TestCase) ... ok
test_T3 (__main__.T1TestCase) ... ok
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK
'''
More information about the Python-list
mailing list