From 3945c36f3023890c63cc93f3de25454f06720c2a Mon Sep 17 00:00:00 2001 From: Pablo Hoffman Date: Sat, 11 Apr 2009 05:01:37 +0000 Subject: [PATCH] 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 --HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%401049 --- scrapy/trunk/scrapy/tests/__init__.py | 16 +++------------- scrapy/trunk/scrapy/tests/run.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 scrapy/trunk/scrapy/tests/run.py 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)