]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #13308: Fix test_httpservers failures when run as root.
authorCharles-François Natali <neologix@free.fr>
Wed, 2 Nov 2011 18:35:14 +0000 (19:35 +0100)
committerCharles-François Natali <neologix@free.fr>
Wed, 2 Nov 2011 18:35:14 +0000 (19:35 +0100)
Lib/test/test_httpservers.py

index 39ebc263381fc4b48d33189f3b97d35c79a3d0f8..e83c048ed940e1a63bed8adc9226b54d2c7036ca 100644 (file)
@@ -259,8 +259,9 @@ class SimpleHTTPServerTestCase(BaseTestCase):
         with open(os.path.join(self.tempdir_name, 'index.html'), 'w') as f:
             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)
@@ -305,6 +306,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