Fixed #16683 -- Skip the IPv6 runserver tests if the platform doesn't support it.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17183 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2011-12-09 21:50:28 +00:00
parent 1a8b40c9fa
commit 154438e315
1 changed files with 11 additions and 5 deletions

View File

@ -7,6 +7,7 @@ from __future__ import with_statement
import os import os
import shutil import shutil
import socket
import sys import sys
import re import re
@ -1056,10 +1057,13 @@ class ManageValidate(AdminScriptTestCase):
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, '0 errors found') self.assertOutput(out, '0 errors found')
class ManageRunserver(AdminScriptTestCase): class ManageRunserver(AdminScriptTestCase):
def setUp(self): def setUp(self):
from django.core.management.commands.runserver import BaseRunserverCommand from django.core.management.commands.runserver import BaseRunserverCommand
def monkey_run(*args, **options): return
def monkey_run(*args, **options):
return
self.cmd = BaseRunserverCommand() self.cmd = BaseRunserverCommand()
self.cmd.run = monkey_run self.cmd.run = monkey_run
@ -1080,7 +1084,8 @@ class ManageRunserver(AdminScriptTestCase):
self.cmd.handle(addrport="7000") self.cmd.handle(addrport="7000")
self.assertServerSettings('127.0.0.1', '7000') self.assertServerSettings('127.0.0.1', '7000')
# IPv6 @unittest.skipUnless(socket.has_ipv6, 'markdown is installed')
def test_runner_addrport_ipv6(self):
self.cmd.handle(addrport="", use_ipv6=True) self.cmd.handle(addrport="", use_ipv6=True)
self.assertServerSettings('::1', '8000', ipv6=True, raw_ipv6=True) self.assertServerSettings('::1', '8000', ipv6=True, raw_ipv6=True)
@ -1090,18 +1095,19 @@ class ManageRunserver(AdminScriptTestCase):
self.cmd.handle(addrport="[2001:0db8:1234:5678::9]:7000") self.cmd.handle(addrport="[2001:0db8:1234:5678::9]:7000")
self.assertServerSettings('2001:0db8:1234:5678::9', '7000', ipv6=True, raw_ipv6=True) self.assertServerSettings('2001:0db8:1234:5678::9', '7000', ipv6=True, raw_ipv6=True)
# Hostname def test_runner_hostname(self):
self.cmd.handle(addrport="localhost:8000") self.cmd.handle(addrport="localhost:8000")
self.assertServerSettings('localhost', '8000') self.assertServerSettings('localhost', '8000')
self.cmd.handle(addrport="test.domain.local:7000") self.cmd.handle(addrport="test.domain.local:7000")
self.assertServerSettings('test.domain.local', '7000') self.assertServerSettings('test.domain.local', '7000')
@unittest.skipUnless(socket.has_ipv6, 'markdown is installed')
def test_runner_hostname_ipv6(self):
self.cmd.handle(addrport="test.domain.local:7000", use_ipv6=True) self.cmd.handle(addrport="test.domain.local:7000", use_ipv6=True)
self.assertServerSettings('test.domain.local', '7000', ipv6=True) self.assertServerSettings('test.domain.local', '7000', ipv6=True)
# Potentially ambiguous def test_runner_ambiguous(self):
# Only 4 characters, all of which could be in an ipv6 address # Only 4 characters, all of which could be in an ipv6 address
self.cmd.handle(addrport="beef:7654") self.cmd.handle(addrport="beef:7654")
self.assertServerSettings('beef', '7654') self.assertServerSettings('beef', '7654')