diff --git a/bin/runtests.bat b/bin/runtests.bat new file mode 100644 index 000000000..8a0869938 --- /dev/null +++ b/bin/runtests.bat @@ -0,0 +1,19 @@ +@ECHO off + +SET test="scrapy" +IF NOT "%1" == "" SET test="%1" + +IF EXIST c:\python26\scripts\trial.py GOTO py26 +IF EXIST c:\python25\scripts\trial.py GOTO py25 + +ECHO "Unable to run tests: trial command (included with Twisted) not found" +GOTO end + +:py26 +c:\python26\scripts\trial.py %test% +GOTO end + +:py25 +c:\python25\scripts\trial.py %test% + +:end diff --git a/bin/runtests.sh b/bin/runtests.sh index 20a73c45d..b381e29d8 100755 --- a/bin/runtests.sh +++ b/bin/runtests.sh @@ -3,10 +3,16 @@ # look for twisted trial command in common known locations if [ -x /usr/bin/trial ]; then trial="/usr/bin/trial" +elif [ -x /usr/lib/twisted/bin/trial ]; then + trial="/usr/lib/twisted/bin/trial" elif [ -x /usr/lib64/twisted/bin/trial ]; then trial="/usr/lib64/twisted/bin/trial" +else + echo "Unable to run tests: trial command (included with Twisted) not found" + exit 1 fi + # disable custom settings for running tests in a neutral environment export SCRAPY_SETTINGS_DISABLED=1 diff --git a/scrapy/tests/__init__.py b/scrapy/tests/__init__.py index 46c662312..c77772af5 100644 --- a/scrapy/tests/__init__.py +++ b/scrapy/tests/__init__.py @@ -1,12 +1,14 @@ """ scrapy.tests: this package contains all Scrapy unittests -To run all Scrapy unittests type: +To run all Scrapy unittests go to Scrapy main dir and type: - python -m scrapy.tests.run + bin/runtests.sh + +If you're in windows use runtests.bat instead. Keep in mind that some tests may be skipped if you don't have some (optional) -modules available like MySQLdb or simplejson. +modules available like MySQLdb or simplejson, but that's not a problem. """ import os diff --git a/scrapy/tests/run.py b/scrapy/tests/run.py deleted file mode 100644 index bc58cc747..000000000 --- a/scrapy/tests/run.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -Module to run Scrapy tests - see scrapy.tests docstring -""" - -if __name__ == '__main__': - import os, sys - from twisted.trial import runner, reporter - - tests_to_run = sys.argv[1:] or ['scrapy'] - - os.environ['SCRAPY_SETTINGS_DISABLED'] = '1' - loader = runner.TestLoader() - runner = runner.TrialRunner(reporter.TreeReporter) - suite = loader.loadByNames(tests_to_run, recurse=True) - runner.run(suite)