How to organize test cases with PyUnit
Roy Smith
roy at panix.com
Sun Jul 7 21:53:43 EDT 2002
OK, now I'm stumped. I've got the following in rulexParser_unit.py:
====================================
import sys
import unittest
from types import *
sys.path.insert (1, '..')
import rulexParser
class parserTestCase (unittest.TestCase):
def setUp (self):
self.parser = rulexParser.rulexParser()
class dictionaryEntries (parserTestCase):
def runTest (self):
tables = self.parser.parse ('data/rulex.envmon')
self.assertEqual (type (tables), DictType)
self.assertEqual (1, 0)
for table in tables:
print type(table)
self.assertEqual (type (table), DictType)
if __name__ == "__main__":
dictionaryEntries().run()
====================================
parser.parse() is supposed to (and does) return a dictionary of
dictionaries. The line "for table in tables:" should read "for table in
tables.keys():". As written, it should raise a TypeError. In the
process of trying to figure out why it wasn't, I added the "print
type(table)" line, and it doesn't print anything. Then I added the
"assertEqual (1, 0)", and it still does nothing.
Obviously, I'm doing something wrong. I suspect something has wrapped
my methon in a try block that catches all these exceptions, but then
doesn't do anything with them.
More information about the Python-list
mailing list