def run_all_tests(): """ Run all unit tests in this folder """ test_base.setUp() # Get location of this module curdir = os.path.abspath(os.path.dirname(test_base.__file__)) sys.path.append(curdir) # 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
# -- coding: utf-8 """ Unit test for urlcollections module Created: Anand B Pillai <*****@*****.**> Jul 18 2008 Copyright (C) 2008, Anand B Pillai. """ import test_base import unittest test_base.setUp() from harvestman.lib.urltypes import * from harvestman.lib.urlcollections import * from harvestman.lib.urlparser import * class TestHarvestManUrlCollections(unittest.TestCase): """ Unit test class for all classes in urltypes module """ def test_urlcollections(self): srcurl = HarvestManUrl('http://www.foo.com', urltype=URL_TYPE_WEBPAGE) child_url1 = HarvestManUrl('url1.html', baseurl=srcurl) child_url2 = HarvestManUrl('url2.html', baseurl=srcurl) child_css = HarvestManUrl('test.css', urltype=URL_TYPE_STYLESHEET, baseurl=srcurl) indices = [obj.index for obj in (child_url1, child_url2, child_css)] indices.sort() coll = HarvestManAutoUrlCollection(srcurl)
# -- coding: latin-1 """ Unit test for urlparser module Created: Anand B Pillai <*****@*****.**> Apr 17 2007 Copyright (C) 2007, Anand B Pillai. """ import test_base import unittest import sys, os test_base.setUp() class TestHarvestManUrlParser(unittest.TestCase): """ Unit test class for HarvestManUrlParser class """ from urlparser import HarvestManUrlParser l = [ HarvestManUrlParser('http://www.yahoo.com/photos/my photo.gif'), HarvestManUrlParser('http://www.rediff.com:80/r/r/tn2/2003/jun/25usfed.htm'), HarvestManUrlParser('http://cwc2003.rediffblogs.com'), HarvestManUrlParser('/sports/2003/jun/25beck1.htm', 'generic', 0, 'http://www.rediff.com', ''), HarvestManUrlParser('ftp://ftp.gnu.org/pub/lpf.README'), HarvestManUrlParser('http://www.python.org/doc/2.3b2/'), HarvestManUrlParser('//images.sourceforge.net/div.png', 'image', 0, 'http://sourceforge.net', ''), HarvestManUrlParser('http://pyro.sourceforge.net/manual/LICENSE'), HarvestManUrlParser('python/test.htm', 'generic', 0, 'http://www.foo.com/bar/index.html', ''),