[Python-modules-commits] [python-llfuse] 01/03: Don't use pytest.skip at module level.
Nikolaus Rath
nikratio-guest at moszumanska.debian.org
Sat Sep 24 04:04:06 UTC 2016
This is an automated email from the git hooks/post-receive script.
nikratio-guest pushed a commit to branch master
in repository python-llfuse.
commit 19b0db84e5635cc8f33ffe8d08b78bce7135443c
Author: Nikolaus Rath <Nikolaus at rath.org>
Date: Fri Sep 23 20:38:53 2016 -0700
Don't use pytest.skip at module level.
Origin: upstream
Forwarded: not-needed
Patch-Name: pytest-skip.diff
This was cherry picked from upstream. pytest 3 no longer support
pytest.skip at module level.
---
test/test_examples.py | 4 ++--
test/test_fs.py | 5 ++---
test/util.py | 20 ++++++++++++++------
3 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/test/test_examples.py b/test/test_examples.py
index 707c725..0e8f6cd 100755
--- a/test/test_examples.py
+++ b/test/test_examples.py
@@ -25,12 +25,12 @@ import shutil
import filecmp
import errno
from tempfile import NamedTemporaryFile
-from util import skip_if_no_fuse, wait_for_mount, umount, cleanup
+from util import fuse_test_marker, wait_for_mount, umount, cleanup
basename = os.path.join(os.path.dirname(__file__), '..')
TEST_FILE = __file__
-skip_if_no_fuse()
+pytestmark = fuse_test_marker()
with open(TEST_FILE, 'rb') as fh:
TEST_DATA = fh.read()
diff --git a/test/test_fs.py b/test/test_fs.py
index b6c2511..7bbd419 100755
--- a/test/test_fs.py
+++ b/test/test_fs.py
@@ -25,10 +25,9 @@ import stat
import time
import logging
import threading
-from util import skip_if_no_fuse, wait_for_mount, umount, cleanup, wait_for
-
-skip_if_no_fuse()
+from util import fuse_test_marker, wait_for_mount, umount, cleanup, wait_for
+pytestmark = fuse_test_marker()
@pytest.yield_fixture()
def testfs(tmpdir):
diff --git a/test/util.py b/test/util.py
index 2e8fe3e..043fd91 100644
--- a/test/util.py
+++ b/test/util.py
@@ -23,12 +23,18 @@ import sys
if sys.version_info[0] == 2:
subprocess.DEVNULL = open('/dev/null', 'w')
-def skip_if_no_fuse():
- '''Skip test if system/user/environment does not support FUSE'''
+def fuse_test_marker():
+ '''Return a pytest.marker that indicates FUSE availability
+
+ If system/user/environment does not support FUSE, return
+ a `pytest.mark.skip` object with more details. If FUSE is
+ supported, return `pytest.mark.uses_fuse()`.
+ '''
if platform.system() == 'Darwin':
# No working autodetection, just assume it will work.
return
+ skip = lambda x: pytest.mark.skip(reason=x)
# Python 2.x: Popen is not a context manager...
which = subprocess.Popen(['which', 'fusermount'], stdout=subprocess.PIPE,
@@ -39,25 +45,27 @@ def skip_if_no_fuse():
which.wait()
if not fusermount_path or which.returncode != 0:
- pytest.skip("Can't find fusermount executable")
+ return skip("Can't find fusermount executable")
if not os.path.exists('/dev/fuse'):
- pytest.skip("FUSE kernel module does not seem to be loaded")
+ return skip("FUSE kernel module does not seem to be loaded")
if os.getuid() == 0:
return
mode = os.stat(fusermount_path).st_mode
if mode & stat.S_ISUID == 0:
- pytest.skip('fusermount executable not setuid, and we are not root.')
+ return skip('fusermount executable not setuid, and we are not root.')
try:
fd = os.open('/dev/fuse', os.O_RDWR)
except OSError as exc:
- pytest.skip('Unable to open /dev/fuse: %s' % exc.strerror)
+ return skip('Unable to open /dev/fuse: %s' % exc.strerror)
else:
os.close(fd)
+ return pytest.mark.uses_fuse()
+
def exitcode(process):
if isinstance(process, subprocess.Popen):
return process.poll()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-llfuse.git
More information about the Python-modules-commits
mailing list