From: Robie Basak <robie.basak@canonical.com>
Date: Mon, 17 Mar 2014 17:07:03 +0000
Subject: [PATCH] Skip tests that require Internet access by default

Ubuntu has a quality control policy that states that package tests
should be run automatically as part of a package build. However, in
order to ensure that builds and tests are reproducible from package
source code only, Internet access is disabled in our build
infrastructure.

Therefore, do not run tests that require Internet access by default.

Bug: https://github.com/liris/websocket-client/pull/66
Last-Update: 2014-03-17

---
 test_websocket.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/test_websocket.py b/test_websocket.py
index 0800a3c..d18b609 100644
--- a/test_websocket.py
+++ b/test_websocket.py
@@ -24,6 +24,7 @@ class SSLError(Exception):
 #      "RFC6455: 5.4. Fragmentation"
 #
 TEST_FRAGMENTATION = True
+TEST_WITH_INTERNET = False
 
 TRACABLE = False
 
@@ -293,6 +294,7 @@ def testRecvWithFragmentationAndControlFrame(self):
         self.assertEqual(s.sent[0], "\x8a\x90abcd1\x0e\x06\x05\x12\x07C4.,$D" \
                                     "\x15\n\n\x17")
 
+    @unittest.skipUnless(TEST_WITH_INTERNET, "Internet-requiring tests are disabled")
     def testWebSocket(self):
         s = ws.create_connection("ws://echo.websocket.org/")
         self.assertNotEquals(s, None)
@@ -305,6 +307,7 @@ def testWebSocket(self):
         self.assertEquals(result, "こにゃにゃちは、世界")
         s.close()
 
+    @unittest.skipUnless(TEST_WITH_INTERNET, "Internet-requiring tests are disabled")
     def testPingPong(self):
         s = ws.create_connection("ws://echo.websocket.org/")
         self.assertNotEquals(s, None)
@@ -328,6 +331,7 @@ def testSecureWebSocket(self):
         except:
             pass
 
+    @unittest.skipUnless(TEST_WITH_INTERNET, "Internet-requiring tests are disabled")
     def testWebSocketWihtCustomHeader(self):
         s = ws.create_connection("ws://echo.websocket.org/",
                                  headers={"User-Agent": "PythonWebsocketClient"})
@@ -337,6 +341,7 @@ def testWebSocketWihtCustomHeader(self):
         self.assertEquals(result, "Hello, World")
         s.close()
 
+    @unittest.skipUnless(TEST_WITH_INTERNET, "Internet-requiring tests are disabled")
     def testAfterClose(self):
         from socket import error
         s = ws.create_connection("ws://echo.websocket.org/")
@@ -371,6 +376,7 @@ def tearDown(self):
         WebSocketAppTest.keep_running_close = WebSocketAppTest.NotSetYet()
         WebSocketAppTest.get_mask_key_id = WebSocketAppTest.NotSetYet()
 
+    @unittest.skipUnless(TEST_WITH_INTERNET, "Internet-requiring tests are disabled")
     def testKeepRunning(self):
         """ A WebSocketApp should keep running as long as its self.keep_running
         is not False (in the boolean context).
@@ -400,6 +406,7 @@ def on_close(self, *args, **kwargs):
         self.assertEquals(True, WebSocketAppTest.keep_running_open)
         self.assertEquals(False, WebSocketAppTest.keep_running_close)
 
+    @unittest.skipUnless(TEST_WITH_INTERNET, "Internet-requiring tests are disabled")
     def testSockMaskKey(self):
         """ A WebSocketApp should forward the received mask_key function down
         to the actual socket.
@@ -423,6 +430,7 @@ def on_open(self, *args, **kwargs):
 
 
 class SockOptTest(unittest.TestCase):
+    @unittest.skipUnless(TEST_WITH_INTERNET, "Internet-requiring tests are disabled")
     def testSockOpt(self):
         sockopt = ((socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),)
         s = ws.WebSocket(sockopt=sockopt)
-- 
1.8.5.5

