mirror of
https://github.com/django/django.git
synced 2025-08-01 09:32:50 +00:00
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
This commit is contained in:
parent
45e3dff5ac
commit
2f02a05ffb
21 changed files with 921 additions and 46 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue