Example #1
0
 def test_sets_reuseaddr(self):
     patch_socket(self)
     with udp_socket() as sock:
         pass
     self.assertEqual(
         [mock.call(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)],
         sock.setsockopt.mock_calls)
Example #2
0
 def test_yields_open_socket(self):
     patch_socket(self)
     with udp_socket() as sock:
         socket_calls = list(socket.socket.mock_calls)
         close_calls = list(sock.close.mock_calls)
     self.assertEqual([mock.call(socket.AF_INET, socket.SOCK_DGRAM)],
                      socket_calls)
     self.assertEqual([], close_calls)
Example #3
0
 def test_closes_socket_on_exit(self):
     patch_socket(self)
     with udp_socket() as sock:
         pass
     self.assertEqual([mock.call()], sock.close.mock_calls)