Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added test runner option to skip Selenium tests (#19854).

  • Loading branch information...
commit 1cd2f51eb43f9ed043982770b4efd5f28f53f302 1 parent 687d2e9
Zbigniew Siciarz authored February 23, 2013
4  django/contrib/admin/tests.py
... ...
@@ -1,3 +1,5 @@
  1
+import os
  2
+
1 3
 from django.test import LiveServerTestCase
2 4
 from django.utils.module_loading import import_by_path
3 5
 from django.utils.unittest import SkipTest
@@ -8,6 +10,8 @@ class AdminSeleniumWebDriverTestCase(LiveServerTestCase):
8 10
 
9 11
     @classmethod
10 12
     def setUpClass(cls):
  13
+        if os.environ.get('DJANGO_SKIP_SELENIUM_TESTS', False):
  14
+            raise SkipTest('Selenium tests skipped by explicit request')
11 15
         try:
12 16
             cls.selenium = import_by_path(cls.webdriver_class)()
13 17
         except Exception as e:
9  docs/internals/contributing/writing-code/unit-tests.txt
@@ -136,6 +136,15 @@ Then, run the tests normally, for example:
136 136
 
137 137
     ./runtests.py --settings=test_sqlite admin_inlines
138 138
 
  139
+If you have Selenium installed but for some reason don't want to run these tests
  140
+(for example to speed up the test suite), use the ``--skip-selenium`` option
  141
+of the test runner.
  142
+
  143
+.. code-block:: bash
  144
+
  145
+    ./runtests.py --settings=test_sqlite --skip-selenium admin_inlines
  146
+
  147
+
139 148
 .. _running-unit-tests-dependencies:
140 149
 
141 150
 Running all the tests
5  tests/regressiontests/views/tests/i18n.py
@@ -2,6 +2,7 @@
2 2
 from __future__ import absolute_import
3 3
 
4 4
 import gettext
  5
+import os
5 6
 from os import path
6 7
 
7 8
 from django.conf import settings
@@ -176,6 +177,10 @@ def testI18NWithLocalePaths(self):
176 177
                     javascript_quote('este texto de app3 debe ser traducido'))
177 178
 
178 179
 
  180
+skip_selenium = os.environ.get('DJANGO_SKIP_SELENIUM_TESTS', False)
  181
+
  182
+
  183
+@unittest.skipIf(skip_selenium, 'Selenium tests skipped by explicit request')
179 184
 @unittest.skipUnless(firefox, 'Selenium not installed')
180 185
 class JavascriptI18nTests(LiveServerTestCase):
181 186
     urls = 'regressiontests.views.urls'
10  tests/runtests.py
@@ -301,7 +301,12 @@ def paired_tests(paired_test, options, test_labels):
301 301
         '--liveserver', action='store', dest='liveserver', default=None,
302 302
         help='Overrides the default address where the live server (used with '
303 303
              'LiveServerTestCase) is expected to run from. The default value '
304  
-             'is localhost:8081.'),
  304
+             'is localhost:8081.')
  305
+    parser.add_option(
  306
+        '--skip-selenium', action='store_true', dest='skip_selenium',
  307
+        default=False,
  308
+        help='Skip running Selenium tests even it Selenium itself is '
  309
+             'installed. By default these tests are not skipped.')
305 310
     options, args = parser.parse_args()
306 311
     if options.settings:
307 312
         os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
@@ -314,6 +319,9 @@ def paired_tests(paired_test, options, test_labels):
314 319
     if options.liveserver is not None:
315 320
         os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = options.liveserver
316 321
 
  322
+    if options.skip_selenium:
  323
+        os.environ['DJANGO_SKIP_SELENIUM_TESTS'] = '1'
  324
+
317 325
     if options.bisect:
318 326
         bisect_tests(options.bisect, options, args)
319 327
     elif options.pair:

0 notes on commit 1cd2f51

Please sign in to comment.
Something went wrong with that request. Please try again.