Skip to content

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

Make scrapyd.eggutils compatible with Python 2.5 and added tests for get_spider_list_from_eggfile() function (closes #242)

Pablo Hoffman400c4134af7d
diff --git a/scrapyd/eggutils.py b/scrapyd/eggutils.py
index 1e1975580..c507f0be5 100644
--- a/scrapyd/eggutils.py
+++ b/scrapyd/eggutils.py
@@ -1,3 +1,5 @@
+from __future__ import with_statement
+
import os, sys, shutil, pkg_resources
from subprocess import Popen, PIPE
from tempfile import NamedTemporaryFile, mkdtemp
diff --git a/scrapyd/tests/mybot.egg b/scrapyd/tests/mybot.egg
new file mode 100644
index 000000000..8525589bb
Binary files /dev/null and b/scrapyd/tests/mybot.egg differ
diff --git a/scrapyd/tests/test_eggutils.py b/scrapyd/tests/test_eggutils.py
new file mode 100644
index 000000000..ec6d00269
--- /dev/null
+++ b/scrapyd/tests/test_eggutils.py
@@ -0,0 +1,11 @@
+import pkgutil, unittest
+from cStringIO import StringIO
+
+from scrapyd.eggutils import get_spider_list_from_eggfile
+
+class EggUtilsTest(unittest.TestCase):
+
+ def test_get_spider_list_from_eggfile(self):
+ eggfile = StringIO(pkgutil.get_data(__package__, 'mybot.egg'))
+ spiders = get_spider_list_from_eggfile(eggfile, 'mybot')
+ self.assertEqual(set(spiders), set(['spider1', 'spider2']))