Beispiel #1
0
 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')
Beispiel #2
0
 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')
Beispiel #3
0
 def test_has_ipv6_disabled_on_compile(self):
     with patch('socket.has_ipv6', False):
         assert not _has_ipv6('::1')
Beispiel #4
0
 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')
Beispiel #5
0
 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")
Beispiel #6
0
 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")
Beispiel #7
0
 def test_has_ipv6_disabled_on_compile(self):
     with patch("socket.has_ipv6", False):
         assert not _has_ipv6("::1")
Beispiel #8
0
 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'))
Beispiel #9
0
 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'))
Beispiel #10
0
 def test_has_ipv6_disabled_on_compile(self):
     with patch('socket.has_ipv6', False):
         self.assertFalse(_has_ipv6('::1'))
Beispiel #11
0
 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')