[Tutor] import and unittest
Duncan Gibson
duncan at thermal.esa.int
Tue Jan 16 14:53:15 CET 2007
> I wondered if it was possible to do something like this:
>
> src/
> -a_module/
> -sub_module/
> test/
> -a_module/
> -sub_module/
Why not really keep the test code with the main code?
# module code here
#
if __name__ == '__main__':
import unittest
class TestModuleCode(unittest.TestCase):
""" test harness for Module code """
def setUp(self):
""" boiler plate for multiple tests """
pass
def testSomething
""" ensure something happens as expected """
pass
unittest.main()
I even have some files where I test for command line parameters
and if so I process those. If not, I run the unittests.
Cheers
Duncan
More information about the Tutor
mailing list