From: Ben Darnell Date: Sat, 22 Jun 2019 16:50:07 +0000 (-0400) Subject: test: Skip test_source_port_fail when running as root X-Git-Tag: v6.1.0b1~67^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2684%2Fhead;p=thirdparty%2Ftornado.git test: Skip test_source_port_fail when running as root 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. --- diff --git a/tornado/test/tcpclient_test.py b/tornado/test/tcpclient_test.py index bd08f08d6..ab08cbf57 100644 --- a/tornado/test/tcpclient_test.py +++ b/tornado/test/tcpclient_test.py @@ -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,