PK\/3,Ñy''testgears/__init__.py"""TestGears extensions to unittest. TestGears provides automatic discovery of unittest.TestCases and the ability to run tests that are written as simple functions. It generates a standard unittest.TestSuite for use with any of the standard frontends, and provides a distutils command to run tests with zero configuration. """ __version__ = "0.2" __author__ = "Kevin Dangoor" __email__ = "dangoor+testgears@gmail.com" __copyright__ = "Copyright 2005 Kevin Dangoor" __license__ = "MIT" from testgears import command TestCommand = command.TestCommandPKS§C8Òb®Láátestgears/command.pyc;ò (”)Cc@s7dklZdklZdeifd„ƒYZdS((sDistutilsOptionError(stests TestCommandcBsAtZdZdddfdddfgZeZeZd„ZRS(sdA derivative of the setuptools test command that automatically scans the main package for tests.s packages=spsRun tests in packagesregex=srs3Search filenames/testnames for a regular expressioncCs¦dk}|itjo|ii|_n't|itƒo|ig|_n|id}t|hhƒ}|i ||i ƒ|_ ||_ tii|ƒdS(Ni(s collectorsselfspackagessNones distributions isinstancesstrspackages __import__smods Collectorsregexs test_suites test_modulestestsfinalize_options(sselfspackages collectorsmod((s5build/bdist.darwin-8.0.1-x86/egg/testgears/command.pysfinalize_optionss   (s__name__s __module__s__doc__s user_optionssNonespackagessregexsfinalize_options(((s5build/bdist.darwin-8.0.1-x86/egg/testgears/command.pys TestCommands N(sdistutils.errorssDistutilsOptionErrorssetuptools.commandstests TestCommand(stestsDistutilsOptionErrors TestCommand((s5build/bdist.darwin-8.0.1-x86/egg/testgears/command.pys?s  PKS§C8ÎJ…¼¼testgears/collector.pyc;ò (”)Cc@sydkZdkZdkZdkZdeifd„ƒYZdefd„ƒYZd„Zdeifd„ƒYZ dS(Ns FunctionTestcBs)tZdZd„Zd„Zd„ZRS(sRuns a single function as a test. Produces output that looks a little different than that of unittest's own FunctionTestCase.cGs&||_||_tii|ƒdS(s(@param func: function to run as a test.N(sfuncsselfsargssunittestsTestCases__init__(sselfsfuncsargs((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pys__init__ s  cCsA|iio|ii}n |ii}d||iifSdS(sVUses the function's doc string as the ideal form. Otherwise, the name is used.s%s (%s)N(sselfsfuncs__doc__snames func_names __module__(sselfsname((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pysshortDescriptions   cCs|i|iŒdS(N(sselfsfuncsargs(sself((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pysrunTests(s__name__s __module__s__doc__s__init__sshortDescriptionsrunTest(((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pys FunctionTests   s SetupFunctioncBstZdZd„ZRS(s‚Runs a setup or teardown function. Does not count in the total test count, but masquerades as a test for convenient execution.cCsdSdS(Ni((sself((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pyscountTestCases s(s__name__s __module__s__doc__scountTestCases(((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pys SetupFunctions cCst|ii|iiƒSdS(sLCompares two functions' line numbers to ensure tests run in file order.N(scmpsas func_codesco_firstlinenosb(sasb((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pyscmpFunctionLocation#ss CollectorcBs2tZdZeZed„Zd„Zd„ZRS(sTA TestSuite that is automatically built from tests in the supplied package. c Cstt|ƒiƒ|oti|ƒ|_nt|t ƒt ƒƒ} t i i t i i| iƒƒ}x˜t i|ƒD]‡\}}}d|jp d|joqyn|t|ƒd}|o&d||it i idƒf}n|}|i||ƒqyWdS(s™@packagename a string name for the package to look up and search @regex a regular expression to match against filenames and test namess.svns.cvsis%s.%ss.N(ssupers Collectorsselfs__init__sregexsrescompiles __import__s packagenamesdictsmodsosspathsabspathsdirnames__file__s packagedirswalksrootsdirssfilesslens currentdirsreplacessepscurrentpackages _processFiles( sselfs packagenamesregexsdirss currentdirscurrentpackages packagedirsrootsfilessmod((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pys__init__/s!&cCsœ|i}xŒ|D]„}t}|o|i|ƒo t}qAn|idƒoCt i i |ƒ\}}|djoqn|i|||ƒqqWdS(Nstest_s.py(sselfsregexsfilessfilesFalsesismatchssearchsTrues startswithsosspathssplitextsfilenamesexts_processModulescurrentpackage(sselfsfilesscurrentpackagesregexsfilenamesextsismatchsfile((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pys _processFilesHs   c Cs§|i}td||ftƒtƒ|ƒ} t| ƒ} t | dƒo|i t | i | ƒƒng}xÕ| D]Í}|o| o|i|ƒ oqtnt| |ƒ}t|ƒtijot|tiƒo#ti}|i |i|ƒƒqtt|ƒtijo/|iƒidƒ oqtn|i|ƒqtqtW|i t!ƒx!|D]} |i t#| ƒƒqYWt | dƒo|i t | i$| ƒƒndS(Ns%s.%ss setup_modulesteststeardown_module(%sselfsregexs __import__scurrentpackagesfilenamesdictsmodsdirs candidatesshasattrsaddTests SetupFunctions setup_modules addInOrders candidatenamesismatchssearchsgetattrs candidatestypestypessTypeTypes issubclasssunittestsTestCasesdefaultTestLoadersloadersloadTestsFromTestCases FunctionTypeslowers startswithsappendssortscmpFunctionLocationsfuncs FunctionTeststeardown_module( sselfsfilenamescurrentpackagesismatchsloadersregexs candidates addInOrders candidatenames candidatessfuncsmod((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pys_processModuleWs2   )  (s__name__s __module__s__doc__sNonesregexs__init__s _processFiless_processModule(((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pys Collector)s   ( sunittestsosstypessresTestCases FunctionTests SetupFunctionscmpFunctionLocations TestSuites Collector(s SetupFunctions FunctionTests CollectorsunittestsrescmpFunctionLocationsosstypes((s7build/bdist.darwin-8.0.1-x86/egg/testgears/collector.pys?s     PK\/3ªk©aMMtestgears/collector.pyimport unittest import os import types import re class FunctionTest(unittest.TestCase): """Runs a single function as a test. Produces output that looks a little different than that of unittest's own FunctionTestCase.""" def __init__(self, func, *args): """@param func: function to run as a test.""" self.func = func self.args = args unittest.TestCase.__init__(self) def shortDescription(self): """Uses the function's doc string as the ideal form. Otherwise, the name is used.""" if self.func.__doc__: name = self.func.__doc__ else: name = self.func.func_name return "%s (%s)" % (name, self.func.__module__) def runTest(self): self.func(*self.args) class SetupFunction(FunctionTest): """Runs a setup or teardown function. Does not count in the total test count, but masquerades as a test for convenient execution.""" def countTestCases(self): return 0 def cmpFunctionLocation(a, b): """Compares two functions' line numbers to ensure tests run in file order.""" return cmp(a.func_code.co_firstlineno, b.func_code.co_firstlineno) class Collector(unittest.TestSuite): """A TestSuite that is automatically built from tests in the supplied package. """ regex = None def __init__(self, packagename, regex=None): """@packagename a string name for the package to look up and search @regex a regular expression to match against filenames and test names""" super(Collector, self).__init__() if regex: self.regex = re.compile(regex) mod = __import__(packagename, dict(), dict()) packagedir = os.path.abspath(os.path.dirname(mod.__file__)) for root, dirs, files in os.walk(packagedir): if ".svn" in root or ".cvs" in root: continue currentdir = root[len(packagedir)+1:] if currentdir: currentpackage = "%s.%s" % (packagename, currentdir.replace(os.path.sep, ".")) else: currentpackage = packagename self._processFiles(files, currentpackage) def _processFiles(self, files, currentpackage): regex = self.regex for file in files: ismatch = False if regex: if regex.search(file): ismatch = True if file.startswith("test_"): filename, ext = os.path.splitext(file) if ext != ".py": continue self._processModule(filename, currentpackage, ismatch) def _processModule(self, filename, currentpackage, ismatch): regex = self.regex mod = __import__("%s.%s" % (currentpackage, filename), dict(), dict(), currentpackage) candidates = dir(mod) if hasattr(mod, "setup_module"): self.addTest(SetupFunction(mod.setup_module, mod)) addInOrder = [] for candidatename in candidates: if regex and not ismatch and not regex.search(candidatename): continue candidate = getattr(mod, candidatename) if type(candidate) == types.TypeType and \ issubclass(candidate, unittest.TestCase): loader = unittest.defaultTestLoader self.addTest(loader.loadTestsFromTestCase( candidate)) elif type(candidate) == types.FunctionType: if not candidatename.lower().startswith("test"): continue addInOrder.append(candidate) addInOrder.sort(cmpFunctionLocation) for func in addInOrder: self.addTest(FunctionTest(func)) if hasattr(mod, "teardown_module"): self.addTest(SetupFunction(mod.teardown_module, mod)) PK\/3sd¬¬testgears/command.pyfrom distutils.errors import DistutilsOptionError from setuptools.command import test class TestCommand(test.test): """A derivative of the setuptools test command that automatically scans the main package for tests.""" user_options = [ ('packages=', 'p', "Run tests in package"), ('regex=', 'r', 'Search filenames/testnames for a regular expression') ] packages = None regex = None def finalize_options(self): import collector if self.packages is None: self.packages = self.distribution.packages elif isinstance(self.packages, str): self.packages = [self.packages] package = self.packages[0] mod = __import__(package, {}, {}) mod.test_suite = collector.Collector(package, self.regex) self.test_module = package test.test.finalize_options(self) PKR§C8í ³ xxtestgears/__init__.pyc;ò (”)Cc@s>dZdZdZdZdZdZdklZeiZdS(sATestGears extensions to unittest. TestGears provides automatic discovery of unittest.TestCases and the ability to run tests that are written as simple functions. It generates a standard unittest.TestSuite for use with any of the standard frontends, and provides a distutils command to run tests with zero configuration. s0.2s Kevin Dangoorsdangoor+testgears@gmail.comsCopyright 2005 Kevin DangoorsMIT(scommandN( s__doc__s __version__s __author__s __email__s __copyright__s __license__s testgearsscommands TestCommand(s __copyright__s TestCommands __license__s __author__s __email__scommands __version__((s6build/bdist.darwin-8.0.1-x86/egg/testgears/__init__.pys?s PK\/3testgears/tests/__init__.pyPKS§C8ÀÚUU#testgears/tests/test_collection.pyc;ò (”)Cc@s¦dkZdklZeaeaead„Zd„Zd„Z d„Z d„Z dei fd„ƒYZ d ei fd „ƒYZd „Zd „Zd „ZdS(N(s collectorcCs tadS(N(sTruesmodule_setup_called(smodule((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pys setup_module scCs tadS(s#Tests are run in file order, part 1N(sTruesvalue(((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pystest_testsInFileOrder scCstpt‚dS(sAre they actually in order?N(svaluesAssertionError(((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pys test_aretheyscCs{tidƒ}|id}t|tiƒpt‚|ii djpt‚|id}t|t i ƒpt‚dS(s!Generated suite should look rightstestdatais test_bIsFirstiN( s collectors Collectorscs_testsst1s isinstances FunctionTestsAssertionErrorsfuncs func_namest0sunittests TestSuite(scst0st1((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pystest_suitepropertiess  cCshtidddƒ}t|iƒdjpt‚tidddƒ}t|iƒdjpt‚dS(sBTests can be required to match a regex in the filename or testnamestestdatasregexs .*bIsFirstis .*justatestiN(s collectors Collectorscslens_testssAssertionError(sc((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pystest_regexmatching!s sTestNormalCasecBs#tZd„Zd„Zd„ZRS(NcCs d|_dS(Ni(sselfsfoo(sself((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pyssetUp*scCs|id|iƒdS(s3Setup is called, as it is for normal unittest casesiN(sselfs assertEqualssfoo(sself((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pystest_setupiscalled-scCs|itƒdS(s%TestCases are called before functionsN(sselfsfailIfsvalue(sself((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pystest_testcasebeforefuncs1s(s__name__s __module__ssetUpstest_setupiscalledstest_testcasebeforefuncs(((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pysTestNormalCase(s  sNamesDontMatterForTestCasescBstZd„ZRS(NcCs tadS(s8TestCase classes should be used regardless of their nameN(sTrues name_doesnt_matter_for_testcases(sself((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pystest_thisshouldbecalled7s(s__name__s __module__stest_thisshouldbecalled(((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pysNamesDontMatterForTestCases5scCstpt‚dS(s9TestCase classes should be used regardless of their namesN(s name_doesnt_matter_for_testcasessAssertionError(((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pystest_was_it_called<scCstpt‚dS(ssetup_module should be calledN(smodule_setup_calledsAssertionError(((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pystest_module_setup@scCsdS(N((smodule((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pysteardown_moduleDs(sunittests testgearss collectorsFalses name_doesnt_matter_for_testcasessvaluesmodule_setup_calleds setup_modulestest_testsInFileOrders test_aretheystest_suitepropertiesstest_regexmatchingsTestCasesTestNormalCasesNamesDontMatterForTestCasesstest_was_it_calledstest_module_setupsteardown_module( stest_suitepropertiessTestNormalCasesteardown_modulesunittests test_aretheys setup_modulesNamesDontMatterForTestCasesstest_regexmatchingstest_was_it_calledstest_testsInFileOrderstest_module_setups collector((sCbuild/bdist.darwin-8.0.1-x86/egg/testgears/tests/test_collection.pys?s         PK\/3/¿‡†dd"testgears/tests/test_collection.pyimport unittest from testgears import collector name_doesnt_matter_for_testcases = False value = False module_setup_called = False def setup_module(module): global module_setup_called module_setup_called = True def test_testsInFileOrder(): "Tests are run in file order, part 1" global value value = True def test_arethey(): "Are they actually in order?" assert value def test_suiteproperties(): "Generated suite should look right" c = collector.Collector("testdata") t1 = c._tests[1] assert isinstance(t1, collector.FunctionTest) assert t1.func.func_name == "test_bIsFirst" t0 = c._tests[0] assert isinstance(t0, unittest.TestSuite) def test_regexmatching(): "Tests can be required to match a regex in the filename or testname" c = collector.Collector("testdata", regex=".*bIsFirst") assert len(c._tests) == 1 c = collector.Collector("testdata", regex=".*justatest") assert len(c._tests) == 3 class TestNormalCase(unittest.TestCase): def setUp(self): self.foo = 1 def test_setupiscalled(self): """Setup is called, as it is for normal unittest cases""" self.assertEquals(1, self.foo) def test_testcasebeforefuncs(self): 'TestCases are called before functions' self.failIf(value) class NamesDontMatterForTestCases(unittest.TestCase): def test_thisshouldbecalled(self): "TestCase classes should be used regardless of their name" global name_doesnt_matter_for_testcases name_doesnt_matter_for_testcases = True def test_was_it_called(): "TestCase classes should be used regardless of their names" assert name_doesnt_matter_for_testcases def test_module_setup(): "setup_module should be called" assert module_setup_called def teardown_module(module): pass PKS§C8ª2ŒŒtestgears/tests/__init__.pyc;ò (”)Cc@sdS(N((((s<build/bdist.darwin-8.0.1-x86/egg/testgears/tests/__init__.pys?sPK\/3ó½FVVtestdata/test_justatest.py"""This is not a real test. It is a test test.""" import unittest def test_bIsFirst(): pass def test_aIsSecond(): pass class TestATestCase(unittest.TestCase): def setUp(self): self.foo = 1 def test_usessetup(self): "unittest.TestCases run like normal" self.failUnlessEqual(1, self.foo) PK\/3testdata/__init__.pyPKS§C8¿ËB±ggtestdata/test_justatest.pyc;ò (”)Cc@s>dZdkZd„Zd„Zdeifd„ƒYZdS(s+This is not a real test. It is a test test.NcCsdS(N((((s;build/bdist.darwin-8.0.1-x86/egg/testdata/test_justatest.pys test_bIsFirstscCsdS(N((((s;build/bdist.darwin-8.0.1-x86/egg/testdata/test_justatest.pystest_aIsSecondss TestATestCasecBstZd„Zd„ZRS(NcCs d|_dS(Ni(sselfsfoo(sself((s;build/bdist.darwin-8.0.1-x86/egg/testdata/test_justatest.pyssetUp scCs|id|iƒdS(s"unittest.TestCases run like normaliN(sselfsfailUnlessEqualsfoo(sself((s;build/bdist.darwin-8.0.1-x86/egg/testdata/test_justatest.pystest_usessetups(s__name__s __module__ssetUpstest_usessetup(((s;build/bdist.darwin-8.0.1-x86/egg/testdata/test_justatest.pys TestATestCase s (s__doc__sunittests test_bIsFirststest_aIsSecondsTestCases TestATestCase(s TestATestCasestest_aIsSecondsunittests test_bIsFirst((s;build/bdist.darwin-8.0.1-x86/egg/testdata/test_justatest.pys?s   PKU§C8×Òž……testdata/__init__.pyc;ò (”)Cc@sdS(N((((s5build/bdist.darwin-8.0.1-x86/egg/testdata/__init__.pys?sPKŒ8)8“×2EGG-INFO/zip-safe PKP§C8 { žžEGG-INFO/SOURCES.txtsetup.py TestGears.egg-info/PKG-INFO TestGears.egg-info/SOURCES.txt TestGears.egg-info/dependency_links.txt TestGears.egg-info/entry_points.txt TestGears.egg-info/requires.txt TestGears.egg-info/top_level.txt TestGears.egg-info/zip-safe testdata/__init__.py testdata/test_justatest.py testgears/__init__.py testgears/collector.py testgears/command.py testgears/tests/__init__.py testgears/tests/test_collection.py PKV§C8Zì·‚@@EGG-INFO/entry_points.txt[distutils.commands] testgears = testgears.command:TestCommand PKU§C8“×2EGG-INFO/dependency_links.txt PKU§C8¾[{øÝÝEGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: TestGears Version: 0.2 Summary: TestGears extensions to unittest. Home-page: http://www.turbogears.org/testgears/ Author: Kevin Dangoor Author-email: dangoor+testgears@gmail.com License: MIT Download-URL: http://www.turbogears.org/TestGears-0.2.tar.gz Description: TestGears provides automatic discovery of unittest.TestCases and the ability to run tests that are written as simple functions. It generates a standard unittest.TestSuite for use with any of the standard frontends, and provides a distutils command to run tests with zero configuration. Keywords: unittest testing Platform: any Classifier: Development Status :: 3 - Alpha Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Software Development :: Libraries :: Python Modules PKO§C8MAôAEGG-INFO/requires.txtsetuptools >= 0.6a1PKO§C8¥-Æ!EGG-INFO/top_level.txttestdata testgears PK\/3,Ñy''¤testgears/__init__.pyPKS§C8Òb®Láá¤Ztestgears/command.pycPKS§C8ÎJ…¼¼¤ntestgears/collector.pycPK\/3ªk©aMM¤_ testgears/collector.pyPK\/3sd¬¬¤à0testgears/command.pyPKR§C8í ³ xx¤¾4testgears/__init__.pycPK\/3¤j8testgears/tests/__init__.pyPKS§C8ÀÚUU#¤£8testgears/tests/test_collection.pycPK\/3/¿‡†dd"¤9Ltestgears/tests/test_collection.pyPKS§C8ª2ŒŒ¤ÝStestgears/tests/__init__.pycPK\/3ó½FVV¤£Ttestdata/test_justatest.pyPK\/3¤1Vtestdata/__init__.pyPKS§C8¿ËB±gg¤cVtestdata/test_justatest.pycPKU§C8×Òž……¤\testdata/__init__.pycPKŒ8)8“×2¤»\EGG-INFO/zip-safePKP§C8 { žž¤ë\EGG-INFO/SOURCES.txtPKV§C8Zì·‚@@¤»^EGG-INFO/entry_points.txtPKU§C8“×2¤2_EGG-INFO/dependency_links.txtPKU§C8¾[{øÝݤn_EGG-INFO/PKG-INFOPKO§C8MAôA¤zcEGG-INFO/requires.txtPKO§C8¥-Æ!¤ÀcEGG-INFO/top_level.txtPK¸d