Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

fixed python pass handling in cmdline/commands tests so that it works with new w3lib library

Pablo Hoffman359129adf9d6
diff --git a/scrapy/tests/test_cmdline/__init__.py b/scrapy/tests/test_cmdline/__init__.py
index d08f266f1..2fb08e119 100644
--- a/scrapy/tests/test_cmdline/__init__.py
+++ b/scrapy/tests/test_cmdline/__init__.py
@@ -3,13 +3,12 @@ import os
from subprocess import Popen, PIPE
import unittest
-import scrapy
-
class CmdlineTest(unittest.TestCase):
def setUp(self):
self.env = os.environ.copy()
- self.env['PYTHONPATH'] = os.path.dirname(scrapy.__path__[0])
+ if 'PYTHONPATH' in os.environ:
+ self.env['PYTHONPATH'] = os.environ['PYTHONPATH']
self.env['SCRAPY_SETTINGS_MODULE'] = 'scrapy.tests.test_cmdline.settings'
def _execute(self, *new_args, **kwargs):
diff --git a/scrapy/tests/test_commands.py b/scrapy/tests/test_commands.py
index e2b671d19..170030693 100644
--- a/scrapy/tests/test_commands.py
+++ b/scrapy/tests/test_commands.py
@@ -3,14 +3,12 @@ from __future__ import with_statement
import sys
import os
import subprocess
-from os.path import exists, join, dirname, abspath
+from os.path import exists, join, abspath
from shutil import rmtree
from tempfile import mkdtemp
from twisted.trial import unittest
-import scrapy
-
class ProjectTest(unittest.TestCase):
project_name = 'testproject'
@@ -21,7 +19,8 @@ class ProjectTest(unittest.TestCase):
self.proj_path = join(self.temp_path, self.project_name)
self.proj_mod_path = join(self.proj_path, self.project_name)
self.env = os.environ.copy()
- self.env['PYTHONPATH'] = dirname(scrapy.__path__[0])
+ if 'PYTHONPATH' in os.environ:
+ self.env['PYTHONPATH'] = os.environ['PYTHONPATH']
def tearDown(self):
rmtree(self.temp_path)