diff options
| author | Julien Phalip <jphalip@gmail.com> | 2011-12-22 08:33:58 +0000 |
|---|---|---|
| committer | Julien Phalip <jphalip@gmail.com> | 2011-12-22 08:33:58 +0000 |
| commit | 2f02a05ffb45be68b4164b4785ff1826833150a3 (patch) | |
| tree | d51f7454aeb97a5c35b3045d5d5413691aaf1d00 /tests/regressiontests/admin_scripts/tests.py | |
| parent | 45e3dff5ac697f16829697bc2a899eaeac8986ea (diff) | |
Fixed #2879 -- Added support for the integration with Selenium and other in-browser testing frameworks. Also added the first Selenium tests for `contrib.admin`. Many thanks to everyone for their contributions and feedback: Mikeal Rogers, Dirk Datzert, mir, Simon G., Almad, Russell Keith-Magee, Denis Golomazov, devin, robertrv, andrewbadr, Idan Gazit, voidspace, Tom Christie, hjwp2, Adam Nelson, Jannis Leidel, Anssi Kääriäinen, Preston Holmes, Bruno Renié and Jacob Kaplan-Moss.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17241 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_scripts/tests.py')
| -rw-r--r-- | tests/regressiontests/admin_scripts/tests.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py index 11beddb7e0..72d47adce1 100644 --- a/tests/regressiontests/admin_scripts/tests.py +++ b/tests/regressiontests/admin_scripts/tests.py @@ -13,6 +13,7 @@ import re from django import conf, bin, get_version from django.conf import settings +from django.test.simple import DjangoTestSuiteRunner from django.utils import unittest @@ -1058,6 +1059,50 @@ class ManageValidate(AdminScriptTestCase): self.assertOutput(out, '0 errors found') +class CustomTestRunner(DjangoTestSuiteRunner): + + def __init__(self, *args, **kwargs): + assert 'liveserver' not in kwargs + super(CustomTestRunner, self).__init__(*args, **kwargs) + + def run_tests(self, test_labels, extra_tests=None, **kwargs): + pass + +class ManageTestCommand(AdminScriptTestCase): + def setUp(self): + from django.core.management.commands.test import Command as TestCommand + self.cmd = TestCommand() + + def test_liveserver(self): + """ + Ensure that the --liveserver option sets the environment variable + correctly. + Refs #2879. + """ + + # Backup original state + address_predefined = 'DJANGO_LIVE_TEST_SERVER_ADDRESS' in os.environ + old_address = os.environ.get('DJANGO_LIVE_TEST_SERVER_ADDRESS') + + self.cmd.handle(verbosity=0, testrunner='regressiontests.admin_scripts.tests.CustomTestRunner') + + # Original state hasn't changed + self.assertEqual('DJANGO_LIVE_TEST_SERVER_ADDRESS' in os.environ, address_predefined) + self.assertEqual(os.environ.get('DJANGO_LIVE_TEST_SERVER_ADDRESS'), old_address) + + self.cmd.handle(verbosity=0, testrunner='regressiontests.admin_scripts.tests.CustomTestRunner', + liveserver='blah') + + # Variable was correctly set + self.assertEqual(os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'], 'blah') + + # Restore original state + if address_predefined: + os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = old_address + else: + del os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] + + class ManageRunserver(AdminScriptTestCase): def setUp(self): from django.core.management.commands.runserver import BaseRunserverCommand |
