1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-24 04:04:13 +00:00

some better code reusage

This commit is contained in:
Pablo Hoffman 2009-08-28 18:07:35 -03:00
parent 7dd43da9a5
commit 18e9fd9771

View File

@ -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)