From: Charles-François Natali Date: Wed, 2 Nov 2011 18:32:54 +0000 (+0100) Subject: Issue #13308: Fix test_httpservers failures when run as root. X-Git-Tag: v2.7.3rc1~333 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09f871462f2b6cd53daf7cb43e861737af9ebc52;p=python Issue #13308: Fix test_httpservers failures when run as root. --- diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py index 3de0923efe..97abdf5692 100644 --- a/Lib/test/test_httpservers.py +++ b/Lib/test/test_httpservers.py @@ -324,8 +324,10 @@ class SimpleHTTPServerTestCase(BaseTestCase): f = open(os.path.join(self.tempdir_name, 'index.html'), 'w') response = self.request('/' + self.tempdir_name + '/') self.check_status_and_reason(response, 200) - if os.name == 'posix': - # chmod won't work as expected on Windows platforms + + # chmod() doesn't work as expected on Windows, and filesystem + # permissions are ignored by root on Unix. + if os.name == 'posix' and os.geteuid() != 0: os.chmod(self.tempdir, 0) response = self.request(self.tempdir_name + '/') self.check_status_and_reason(response, 404) @@ -370,6 +372,9 @@ print "%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"), form.getfirst("bacon")) """ + +@unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0, + "This test can't be run reliably as root (issue #13308).") class CGIHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, CGIHTTPRequestHandler): pass