Skip to content

Commit

Permalink
Fixed #19854 -- Turn Django's own Selenium tests off by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Feb 25, 2013
1 parent 6d52bcb commit 906dc85
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
4 changes: 2 additions & 2 deletions django/contrib/admin/tests.py
Expand Up @@ -10,8 +10,8 @@ class AdminSeleniumWebDriverTestCase(LiveServerTestCase):

@classmethod
def setUpClass(cls):
if os.environ.get('DJANGO_SKIP_SELENIUM_TESTS', False):
raise SkipTest('Selenium tests skipped by explicit request')
if not os.environ.get('DJANGO_SELENIUM_TESTS', False):
raise SkipTest('Selenium tests not requested')
try:
cls.selenium = import_by_path(cls.webdriver_class)()
except Exception as e:
Expand Down
15 changes: 3 additions & 12 deletions docs/internals/contributing/writing-code/unit-tests.txt
Expand Up @@ -128,21 +128,12 @@ Running the Selenium tests

Some admin tests require Selenium 2, Firefox and Python >= 2.6 to work via a
real Web browser. To allow those tests to run and not be skipped, you must
install the selenium_ package (version > 2.13) into your Python path.

Then, run the tests normally, for example:

.. code-block:: bash

./runtests.py --settings=test_sqlite admin_inlines

If you have Selenium installed but for some reason don't want to run these tests
(for example to speed up the test suite), use the ``--skip-selenium`` option
of the test runner.
install the selenium_ package (version > 2.13) into your Python path and run
the tests with the ``--selenium`` option:

.. code-block:: bash

./runtests.py --settings=test_sqlite --skip-selenium admin_inlines
./runtests.py --settings=test_sqlite --selenium admin_inlines


.. _running-unit-tests-dependencies:
Expand Down
4 changes: 2 additions & 2 deletions tests/regressiontests/views/tests/i18n.py
Expand Up @@ -177,10 +177,10 @@ def testI18NWithLocalePaths(self):
javascript_quote('este texto de app3 debe ser traducido'))


skip_selenium = os.environ.get('DJANGO_SKIP_SELENIUM_TESTS', False)
skip_selenium = not os.environ.get('DJANGO_SELENIUM_TESTS', False)


@unittest.skipIf(skip_selenium, 'Selenium tests skipped by explicit request')
@unittest.skipIf(skip_selenium, 'Selenium tests not requested')
@unittest.skipUnless(firefox, 'Selenium not installed')
class JavascriptI18nTests(LiveServerTestCase):
urls = 'regressiontests.views.urls'
Expand Down
9 changes: 4 additions & 5 deletions tests/runtests.py
Expand Up @@ -302,10 +302,9 @@ def paired_tests(paired_test, options, test_labels):
'LiveServerTestCase) is expected to run from. The default value '
'is localhost:8081.')
parser.add_option(
'--skip-selenium', action='store_true', dest='skip_selenium',
'--selenium', action='store_true', dest='selenium',
default=False,
help='Skip running Selenium tests even it Selenium itself is '
'installed. By default these tests are not skipped.')
help='Run the Selenium tests as well (if Selenium is installed)')
options, args = parser.parse_args()
if options.settings:
os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
Expand All @@ -318,8 +317,8 @@ def paired_tests(paired_test, options, test_labels):
if options.liveserver is not None:
os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = options.liveserver

if options.skip_selenium:
os.environ['DJANGO_SKIP_SELENIUM_TESTS'] = '1'
if options.selenium:
os.environ['DJANGO_SELENIUM_TESTS'] = '1'

if options.bisect:
bisect_tests(options.bisect, options, args)
Expand Down

0 comments on commit 906dc85

Please sign in to comment.