mirror of https://github.com/django/django.git
Fixed #34068 -- Corrected output of runserver command for "0" IP address.
Thanks David Sanders for the review.
This commit is contained in:
parent
93d4c9ea1d
commit
9fbb5b5e16
|
@ -129,6 +129,13 @@ class Command(BaseCommand):
|
|||
shutdown_message = options.get("shutdown_message", "")
|
||||
quit_command = "CTRL-BREAK" if sys.platform == "win32" else "CONTROL-C"
|
||||
|
||||
if self._raw_ipv6:
|
||||
addr = f"[{self.addr}]"
|
||||
elif self.addr == "0":
|
||||
addr = "0.0.0.0"
|
||||
else:
|
||||
addr = self.addr
|
||||
|
||||
if not options["skip_checks"]:
|
||||
self.stdout.write("Performing system checks...\n\n")
|
||||
self.check(display_num_errors=True)
|
||||
|
@ -147,7 +154,7 @@ class Command(BaseCommand):
|
|||
"version": self.get_version(),
|
||||
"settings": settings.SETTINGS_MODULE,
|
||||
"protocol": self.protocol,
|
||||
"addr": "[%s]" % self.addr if self._raw_ipv6 else self.addr,
|
||||
"addr": addr,
|
||||
"port": self.port,
|
||||
"quit_command": quit_command,
|
||||
}
|
||||
|
|
|
@ -1587,6 +1587,21 @@ class ManageRunserver(SimpleTestCase):
|
|||
call_command(self.cmd, addrport="7000")
|
||||
self.assertServerSettings("127.0.0.1", "7000")
|
||||
|
||||
@mock.patch("django.core.management.commands.runserver.run")
|
||||
@mock.patch("django.core.management.base.BaseCommand.check_migrations")
|
||||
def test_zero_ip_addr(self, *mocked_objects):
|
||||
call_command(
|
||||
"runserver",
|
||||
addrport="0:8000",
|
||||
use_reloader=False,
|
||||
skip_checks=True,
|
||||
stdout=self.output,
|
||||
)
|
||||
self.assertIn(
|
||||
"Starting development server at http://0.0.0.0:8000/",
|
||||
self.output.getvalue(),
|
||||
)
|
||||
|
||||
@unittest.skipUnless(socket.has_ipv6, "platform doesn't support IPv6")
|
||||
def test_runner_addrport_ipv6(self):
|
||||
call_command(self.cmd, addrport="", use_ipv6=True)
|
||||
|
|
Loading…
Reference in New Issue