klenwell information services : PythonTemplateFunctionalTest

Wiki source for PythonTemplateFunctionalTest

Show raw source

=====Python Functional Test Template=====
return to PythonTesting

This template reflects a straightforward unit test. With a little ingenuity, it can be adapted to most functional tests.


A Python Function Test Template
Tom at klenwell@gmail.com
some rights reserved, 2011

Describe test here.

Note: If you change test class name, be sure to update in main block at bottom.

# Imports
# Python Imports
import unittest, sys, os
from os.path import (abspath, dirname, join as osjoin, exists)
from datetime import(datetime, date, timedelta)
from random import (choice, sample)

# Extend sys.path
#basepath = abspath(osjoin(dirname(__file__), '../..'))
#sys.path.append(osjoin(basepath, 'bin'))

# Module Parameters
# Test Configuration
'BREAK' : False,
'VERBOSE' : False,

# Exception Classes

# Test Class
class FunctionalTest(unittest.TestCase):

# Overhead
def setUp(self):

def tearDown(self):

# Tests
def testBreak(self):
"""Set BREAK property in TEST_CONFIG above to True to use Python
debugger to break into test and interact from the command line"""
import pdb; pdb.set_trace()

def testInstance(self):
"""adapt to your purposes, I like to always include this as a sanity check"""
self.assertTrue(isinstance(self, unittest.TestCase))

# Main
if __name__ == "__main__":
mod = sys.modules[globals()['__name__']]
suite = unittest.TestLoader().loadTestsFromModule(mod)