mirror of https://github.com/scrapy/scrapy.git
make sure the mockserver forked from tests uses the current installation of scrapy, not the system one
This commit is contained in:
parent
cf4d4bc094
commit
14e7121674
|
|
@ -5,7 +5,7 @@ from subprocess import Popen, PIPE
|
|||
from scrapy.spider import BaseSpider
|
||||
from scrapy.http import Request
|
||||
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
|
||||
from scrapy.utils.test import get_crawler
|
||||
from scrapy.utils.test import get_crawler, get_testenv
|
||||
|
||||
class FollowAllSpider(BaseSpider):
|
||||
|
||||
|
|
@ -52,7 +52,8 @@ def docrawl(spider, settings=None):
|
|||
class CrawlTestCase(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.proc = Popen([sys.executable, '-u', '-m', 'scrapy.tests.mockserver'], stdout=PIPE)
|
||||
self.proc = Popen([sys.executable, '-u', '-m', 'scrapy.tests.mockserver'],
|
||||
stdout=PIPE, env=get_testenv())
|
||||
self.proc.stdout.readline()
|
||||
|
||||
def tearDown(self):
|
||||
|
|
|
|||
|
|
@ -67,6 +67,14 @@ def get_pythonpath():
|
|||
scrapy_path = __import__('scrapy').__path__[0]
|
||||
return os.path.dirname(scrapy_path) + sep + os.environ.get('PYTHONPATH', '')
|
||||
|
||||
def get_testenv():
|
||||
"""Return a OS environment dict suitable to fork processes that need to import
|
||||
this installation of Scrapy, instead of a system installed one.
|
||||
"""
|
||||
env = os.environ.copy()
|
||||
env['PYTHONPATH'] = get_pythonpath()
|
||||
return env
|
||||
|
||||
def assert_samelines(testcase, text1, text2, msg=None):
|
||||
"""Asserts text1 and text2 have the same lines, ignoring differences in
|
||||
line endings between platforms
|
||||
|
|
|
|||
Loading…
Reference in New Issue