Issue #17746: Skip test_shutil.test_non_matching_mode when run as root or
on unsuitable platform/environment.
This commit is contained in:
commit
5758fa78d0
|
@ -1338,9 +1338,13 @@ class TestWhich(unittest.TestCase):
|
||||||
# Other platforms: shouldn't match in the current directory.
|
# Other platforms: shouldn't match in the current directory.
|
||||||
self.assertIsNone(rv)
|
self.assertIsNone(rv)
|
||||||
|
|
||||||
|
@unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0,
|
||||||
|
'non-root user required')
|
||||||
def test_non_matching_mode(self):
|
def test_non_matching_mode(self):
|
||||||
# Set the file read-only and ask for writeable files.
|
# Set the file read-only and ask for writeable files.
|
||||||
os.chmod(self.temp_file.name, stat.S_IREAD)
|
os.chmod(self.temp_file.name, stat.S_IREAD)
|
||||||
|
if os.access(self.temp_file.name, os.W_OK):
|
||||||
|
self.skipTest("can't set the file read-only")
|
||||||
rv = shutil.which(self.file, path=self.dir, mode=os.W_OK)
|
rv = shutil.which(self.file, path=self.dir, mode=os.W_OK)
|
||||||
self.assertIsNone(rv)
|
self.assertIsNone(rv)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue