def run_test_pageparser(): import test_pageparser print 'Running test_pageparser...' suite = unittest.makeSuite(test_pageparser.TestHarvestManPageParser) result = unittest.TestResult() suite.run(result) test_base.clean_up() return result
def run_test_connector(): import test_connector print 'Running test_connector...' suite = unittest.makeSuite(test_connector.TestHarvestManUrlConnector) result = unittest.TestResult() suite.run(result) test_base.clean_up() return result
def run_test_urlcollections(): import test_urlcollections print 'Running test_urlcollections...' suite = unittest.makeSuite(test_urlcollections.HarvestManUrlCollections) result = unittest.TestResult() suite.run(result) test_base.clean_up() return result
css_css = HarvestManUrl('test.css', urltype=URL_TYPE_STYLESHEET, baseurl=srccss) indices = [obj.index for obj in (css_url1, css_url2, css_css)] indices.sort() coll = HarvestManAutoUrlCollection(srccss) coll.addURL(css_url1) coll.addURL(css_url2) coll.addURL(css_css) assert (coll.getSourceURL() == srccss.index) urlindices = coll.getAllURLs() urlindices.sort() assert (urlindices == indices) assert (coll.getURLs(HarvestManCSS2Context) == [css_css.index]) assert (coll.getURLs(HarvestManCSSContext) == [ css_url1.index, css_url2.index ]) def run(result): return test_base.run_test(TestHarvestManUrlCollections, result) if __name__ == "__main__": s = unittest.makeSuite(TestHarvestManUrlCollections) unittest.TextTestRunner(verbosity=2).run(s) test_base.clean_up()
# Comment following line and uncomment line after it before checking in code... # test_modules = glob.glob(os.path.join(curdir, 'test_[!base|connector]*.py')) test_modules = glob.glob(os.path.join(curdir, 'test_[!base]*.py')) result = unittest.TestResult() for module in test_modules: try: print 'Running unit-test for %s...' % module modpath, modfile = os.path.split(module) m = __import__(modfile.replace('.py','')) m.run(result) except ImportError,e : raise pass test_base.clean_up() return result def run_test_connector(): import test_connector print 'Running test_connector...' suite = unittest.makeSuite(test_connector.TestHarvestManUrlConnector) result = unittest.TestResult() suite.run(result) test_base.clean_up() return result def run_test_urlparser(): import test_urlparser