def test_has_ipv6_enabled_and_working(self): with patch('socket.has_ipv6', True): with patch('socket.socket') as mock: instance = mock.return_value instance.bind.return_value = True assert _has_ipv6('::1')
def test_has_ipv6_disabled_on_appengine(self): gae_patch = patch( 'urllib3.contrib._appengine_environ.is_appengine_sandbox', return_value=True) with gae_patch: assert not _has_ipv6('::1')
def test_has_ipv6_disabled_on_compile(self): with patch('socket.has_ipv6', False): assert not _has_ipv6('::1')
def test_has_ipv6_enabled_but_fails(self): with patch('socket.has_ipv6', True): with patch('socket.socket') as mock: instance = mock.return_value instance.bind = Mock(side_effect=Exception('No IPv6 here!')) assert not _has_ipv6('::1')
def test_has_ipv6_enabled_but_fails(self): with patch("socket.has_ipv6", True): with patch("socket.socket") as mock: instance = mock.return_value instance.bind = Mock(side_effect=Exception("No IPv6 here!")) assert not _has_ipv6("::1")
def test_has_ipv6_enabled_and_working(self): with patch("socket.has_ipv6", True): with patch("socket.socket") as mock: instance = mock.return_value instance.bind.return_value = True assert _has_ipv6("::1")
def test_has_ipv6_disabled_on_compile(self): with patch("socket.has_ipv6", False): assert not _has_ipv6("::1")
def test_has_ipv6_enabled_and_working(self): with patch('socket.has_ipv6', True): with patch('socket.socket') as mock: instance = mock.return_value instance.bind.return_value = True self.assertTrue(_has_ipv6('::1'))
def test_has_ipv6_enabled_but_fails(self): with patch('socket.has_ipv6', True): with patch('socket.socket') as mock: instance = mock.return_value instance.bind = Mock(side_effect=Exception('No IPv6 here!')) self.assertFalse(_has_ipv6('::1'))
def test_has_ipv6_disabled_on_compile(self): with patch('socket.has_ipv6', False): self.assertFalse(_has_ipv6('::1'))