]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
test: Skip test_source_port_fail when running as root 2684/head
authorBen Darnell <ben@bendarnell.com>
Sat, 22 Jun 2019 16:50:07 +0000 (12:50 -0400)
committerBen Darnell <ben@bendarnell.com>
Sat, 22 Jun 2019 16:50:07 +0000 (12:50 -0400)
Root is always allowed to bind to low port numbers, so we can't
simulate failure in this case. This is the last remaining failure when
running tests in docker.

tornado/test/tcpclient_test.py

index bd08f08d6951f30dbaf9031c38f32d473ea23fb7..ab08cbf57cd15c67e805d11e7e114d838df2fd4f 100644 (file)
@@ -13,6 +13,7 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 from contextlib import closing
+import getpass
 import os
 import socket
 import unittest
@@ -135,8 +136,7 @@ class TCPClientTest(AsyncTestCase):
             yield self.client.connect("127.0.0.1", port)
 
     def test_source_ip_fail(self):
-        """
-        Fail when trying to use the source IP Address '8.8.8.8'.
+        """Fail when trying to use the source IP Address '8.8.8.8'.
         """
         self.assertRaises(
             socket.error,
@@ -147,16 +147,18 @@ class TCPClientTest(AsyncTestCase):
         )
 
     def test_source_ip_success(self):
-        """
-        Success when trying to use the source IP Address '127.0.0.1'
+        """Success when trying to use the source IP Address '127.0.0.1'.
         """
         self.do_test_connect(socket.AF_INET, "127.0.0.1", source_ip="127.0.0.1")
 
     @skipIfNonUnix
     def test_source_port_fail(self):
+        """Fail when trying to use source port 1.
         """
-        Fail when trying to use source port 1.
-        """
+        if getpass.getuser() == "root":
+            # Root can use any port so we can't easily force this to fail.
+            # This is mainly relevant for docker.
+            self.skipTest("running as root")
         self.assertRaises(
             socket.error,
             self.do_test_connect,