Fixed #32813 -- Made runserver display port after binding.

Thanks Florian Apolloner for the review.
This commit is contained in:
Dhanush 2023-02-04 01:43:36 +05:30 committed by Mariusz Felisiak
parent 358792486e
commit a18d20ca97
3 changed files with 45 additions and 36 deletions

View file

@ -1585,21 +1585,24 @@ 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,
)
def test_zero_ip_addr(self):
self.cmd.addr = "0"
self.cmd._raw_ipv6 = False
self.cmd.on_bind("8000")
self.assertIn(
"Starting development server at http://0.0.0.0:8000/",
self.output.getvalue(),
)
def test_on_bind(self):
self.cmd.addr = "127.0.0.1"
self.cmd._raw_ipv6 = False
self.cmd.on_bind("14437")
self.assertIn(
"Starting development server at http://127.0.0.1:14437/",
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)