Skip to content

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

added scrapy.tests.run module to support running tests with 'python -m scrapy.tests.run' in Python 2.6, since Python 2.6 doesn't allow running packages with -m

Pablo Hoffman3945c36f3023
diff --git a/scrapy/trunk/scrapy/tests/__init__.py b/scrapy/trunk/scrapy/tests/__init__.py
index b69daf737..caca0592e 100644
--- a/scrapy/trunk/scrapy/tests/__init__.py
+++ b/scrapy/trunk/scrapy/tests/__init__.py
@@ -3,18 +3,8 @@ scrapy.tests: this package contains all Scrapy unittests
To run all Scrapy unittests type:
- python -m scrapy.tests
+ python -m scrapy.tests.run
-Keep in mind that some tests may be skipped if you don't have a MySQL database
-up and configured appropriately.
+Keep in mind that some tests may be skipped if you don't have some (optional)
+modules available like MySQLdb or simplejson.
"""
-
-if __name__ == '__main__':
- import os
- from twisted.trial import runner, reporter
-
- os.environ['SCRAPY_SETTINGS_DISABLED'] = '1'
- loader = runner.TestLoader()
- runner = runner.TrialRunner(reporter.TreeReporter)
- suite = loader.loadByNames(['scrapy'], recurse=True)
- runner.run(suite)
diff --git a/scrapy/trunk/scrapy/tests/run.py b/scrapy/trunk/scrapy/tests/run.py
new file mode 100644
index 000000000..337b0578c
--- /dev/null
+++ b/scrapy/trunk/scrapy/tests/run.py
@@ -0,0 +1,13 @@
+"""
+Module to run Scrapy tests - see scrapy.tests docstring
+"""
+
+if __name__ == '__main__':
+ import os
+ from twisted.trial import runner, reporter
+
+ os.environ['SCRAPY_SETTINGS_DISABLED'] = '1'
+ loader = runner.TestLoader()
+ runner = runner.TrialRunner(reporter.TreeReporter)
+ suite = loader.loadByNames(['scrapy'], recurse=True)
+ runner.run(suite)