summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_shutil.py
diff options
context:
space:
mode:
authorxdegaye <xdegaye@gmail.com>2017-11-12 16:31:07 (GMT)
committerGitHub <noreply@github.com>2017-11-12 16:31:07 (GMT)
commit92c2ca7633c881a56157f2fb8b2e1b8c7114e5fb (patch)
treee2f19b5353b11b39f9f375aaa5e785156b033ada /Lib/test/test_shutil.py
parente0582a37c8d1776a2fd4968e9216f3a05f780276 (diff)
downloadcpython-92c2ca7633c881a56157f2fb8b2e1b8c7114e5fb.zip
cpython-92c2ca7633c881a56157f2fb8b2e1b8c7114e5fb.tar.gz
cpython-92c2ca7633c881a56157f2fb8b2e1b8c7114e5fb.tar.bz2
bpo-28759: Skip some tests on PermissionError raised by Android (GH-4350)
Access to mkfifo(), mknod() and hard link creation is controled by SELinux on Android. Also remove test.support.android_not_root.
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r--Lib/test/test_shutil.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 4a72b4a..f3cf43e 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -22,7 +22,7 @@ import tarfile
import zipfile
from test import support
-from test.support import TESTFN, android_not_root
+from test.support import TESTFN
TESTFN2 = TESTFN + "2"
@@ -769,7 +769,6 @@ class TestShutil(unittest.TestCase):
@unittest.skipIf(os.name == 'nt', 'temporarily disabled on Windows')
@unittest.skipUnless(hasattr(os, 'link'), 'requires os.link')
- @unittest.skipIf(android_not_root, "hard links not allowed, non root user")
def test_dont_copy_file_onto_link_to_itself(self):
# bug 851123.
os.mkdir(TESTFN)
@@ -778,7 +777,10 @@ class TestShutil(unittest.TestCase):
try:
with open(src, 'w') as f:
f.write('cheddar')
- os.link(src, dst)
+ try:
+ os.link(src, dst)
+ except PermissionError as e:
+ self.skipTest('os.link(): %s' % e)
self.assertRaises(shutil.SameFileError, shutil.copyfile, src, dst)
with open(src, 'r') as f:
self.assertEqual(f.read(), 'cheddar')
@@ -822,9 +824,11 @@ class TestShutil(unittest.TestCase):
# Issue #3002: copyfile and copytree block indefinitely on named pipes
@unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()')
- @unittest.skipIf(android_not_root, "mkfifo not allowed, non root user")
def test_copyfile_named_pipe(self):
- os.mkfifo(TESTFN)
+ try:
+ os.mkfifo(TESTFN)
+ except PermissionError as e:
+ self.skipTest('os.mkfifo(): %s' % e)
try:
self.assertRaises(shutil.SpecialFileError,
shutil.copyfile, TESTFN, TESTFN2)
@@ -833,7 +837,6 @@ class TestShutil(unittest.TestCase):
finally:
os.remove(TESTFN)
- @unittest.skipIf(android_not_root, "mkfifo not allowed, non root user")
@unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()')
@support.skip_unless_symlink
def test_copytree_named_pipe(self):
@@ -842,7 +845,10 @@ class TestShutil(unittest.TestCase):
subdir = os.path.join(TESTFN, "subdir")
os.mkdir(subdir)
pipe = os.path.join(subdir, "mypipe")
- os.mkfifo(pipe)
+ try:
+ os.mkfifo(pipe)
+ except PermissionError as e:
+ self.skipTest('os.mkfifo(): %s' % e)
try:
shutil.copytree(TESTFN, TESTFN2)
except shutil.Error as e: