Skip to content

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

some better code reusage

Pablo Hoffman18e9fd977140
diff --git a/scrapy/tests/test_commands.py b/scrapy/tests/test_commands.py
index 5811e287f..3f6d3ddd9 100644
--- a/scrapy/tests/test_commands.py
+++ b/scrapy/tests/test_commands.py
@@ -13,6 +13,8 @@ class ProjectTest(unittest.TestCase):
def setUp(self):
self.temp_path = mkdtemp()
self.cwd = self.temp_path
+ self.proj_path = join(self.temp_path, self.project_name)
+ self.proj_mod_path = join(self.proj_path, self.project_name)
def tearDown(self):
rmtree(self.temp_path)
@@ -29,19 +31,16 @@ class ProjectTest(unittest.TestCase):
class StartprojectTest(ProjectTest):
def test_startproject(self):
- proj_path = join(self.temp_path, self.project_name)
- proj_mod_path = join(proj_path, self.project_name)
-
ret = self.call(['startproject', self.project_name])
self.assertEqual(ret, 0)
- assert exists(join(proj_path, 'scrapy-ctl.py'))
- assert exists(join(proj_path, 'testproject'))
- assert exists(join(proj_mod_path, '__init__.py'))
- assert exists(join(proj_mod_path, 'items.py'))
- assert exists(join(proj_mod_path, 'pipelines.py'))
- assert exists(join(proj_mod_path, 'settings.py'))
- assert exists(join(proj_mod_path, 'spiders', '__init__.py'))
+ assert exists(join(self.proj_path, 'scrapy-ctl.py'))
+ assert exists(join(self.proj_path, 'testproject'))
+ assert exists(join(self.proj_mod_path, '__init__.py'))
+ assert exists(join(self.proj_mod_path, 'items.py'))
+ assert exists(join(self.proj_mod_path, 'pipelines.py'))
+ assert exists(join(self.proj_mod_path, 'settings.py'))
+ assert exists(join(self.proj_mod_path, 'spiders', '__init__.py'))
ret = self.call(['startproject', self.project_name])
self.assertEqual(ret, 1)
@@ -92,8 +91,7 @@ class BaseGenspiderTest(CommandTest):
ret = self.call(['genspider', 'testspider', 'test.com',
'--template=%s' % self.template])
self.assertEqual(ret, 0)
- assert os.path.exists(join(self.cwd, self.project_name, 'spiders', \
- 'testspider.py'))
+ assert exists(join(self.proj_mod_path, 'spiders', 'testspider.py'))
ret = self.call(['genspider', 'otherspider', 'test.com'])
self.assertEqual(ret, 1)