2009-03-05 11:12:07 +00:00
|
|
|
"""
|
2014-07-30 16:53:28 -03:00
|
|
|
tests: this package contains all Scrapy unittests
|
2009-03-05 11:12:07 +00:00
|
|
|
|
2014-07-31 17:30:45 -03:00
|
|
|
see http://doc.scrapy.org/en/latest/contributing.html#running-tests
|
2009-03-05 11:12:07 +00:00
|
|
|
"""
|
2009-05-15 15:03:42 -03:00
|
|
|
|
|
|
|
import os
|
|
|
|
|
2015-07-11 11:27:33 +00:00
|
|
|
# ignore system-wide proxies for tests
|
|
|
|
# which would send requests to a totally unsuspecting server
|
|
|
|
# (e.g. because urllib does not fully understand the proxy spec)
|
|
|
|
os.environ['http_proxy'] = ''
|
|
|
|
os.environ['https_proxy'] = ''
|
|
|
|
os.environ['ftp_proxy'] = ''
|
|
|
|
|
2015-08-13 20:52:38 -03:00
|
|
|
# Absolutize paths to coverage config and output file because tests that
|
|
|
|
# spawn subprocesses also changes current working directory.
|
|
|
|
_sourceroot = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
if 'COV_CORE_CONFIG' in os.environ:
|
|
|
|
os.environ['COVERAGE_FILE'] = os.path.join(_sourceroot, '.coverage')
|
|
|
|
os.environ['COV_CORE_CONFIG'] = os.path.join(_sourceroot,
|
|
|
|
os.environ['COV_CORE_CONFIG'])
|
|
|
|
|
2015-03-06 15:45:04 +02:00
|
|
|
try:
|
|
|
|
import unittest.mock as mock
|
|
|
|
except ImportError:
|
|
|
|
import mock
|
|
|
|
|
2009-05-15 15:03:42 -03:00
|
|
|
tests_datadir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'sample_data')
|
|
|
|
|
|
|
|
def get_testdata(*paths):
|
|
|
|
"""Return test data"""
|
|
|
|
path = os.path.join(tests_datadir, *paths)
|
2009-05-15 19:19:05 -03:00
|
|
|
return open(path, 'rb').read()
|