コード例 #1
0
def test_options():
    with open('.test_generated.txt', 'w') as f:
        s = sys.stdout
        sys.stdout = f

        sys.argv = ['patu.py', 'error.me']

        main()

        sys.stdout = s
    with open('.test_generated.txt', 'r') as f:
        eq_(f.read().strip(), '[500] http://error.me (from None)')
コード例 #2
0
    urls = [unicode(url) for url in args]
    kwargs = {
        'urls': urls,
        'spiders': options.spiders,
        'spinner': options.spinner,
        'verbose': options.verbose,
        'depth': options.depth,
        'generate': options.generate,
        'input_file': options.input_file
    }
    spider = Patu(**kwargs)
    spider.crawl()
    print

if __name__ == '__main__':
    sys.exit(main())

########NEW FILE########
__FILENAME__ = test
import httplib2
from nose.tools import eq_, with_setup
from os import path, remove
import sys

try:
    __file__
except NameError:
    __file__ = 'test/test.py'
sys.path.append(path.join(path.dirname(__file__), '..'))

from patu import Patu, Spinner, main