[pypy-commit] pypy rposix-for-3: Avoid imperative py.test.skip() whenever possible
rlamy
pypy.commits at gmail.com
Thu Mar 31 13:13:29 EDT 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: rposix-for-3
Changeset: r83469:c3eceb0fc5db
Date: 2016-03-31 17:13 +0100
http://bitbucket.org/pypy/pypy/changeset/c3eceb0fc5db/
Log: Avoid imperative py.test.skip() whenever possible
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -11,6 +11,8 @@
return py.test.mark.skipif(not hasattr(rposix, funcname),
reason="Requires rposix.%s()" % funcname)
+win_only = py.test.mark.skipif("os.name != 'nt'")
+
class TestPosixFunction:
def test_access(self):
filename = str(udir.join('test_access.txt'))
@@ -33,9 +35,8 @@
for value in times:
assert isinstance(value, float)
+ @py.test.mark.skipif("not hasattr(os, 'getlogin')")
def test_getlogin(self):
- if not hasattr(os, 'getlogin'):
- py.test.skip('posix specific function')
try:
expected = os.getlogin()
except OSError, e:
@@ -43,9 +44,8 @@
data = rposix.getlogin()
assert data == expected
+ @win_only
def test_utimes(self):
- if os.name != 'nt':
- py.test.skip('Windows specific feature')
# Windows support centiseconds
def f(fname, t1):
os.utime(fname, (t1, t1))
@@ -55,15 +55,12 @@
t1 = 1159195039.25
compile(f, (str, float))(str(fname), t1)
assert t1 == os.stat(str(fname)).st_mtime
- if sys.version_info < (2, 7):
- py.test.skip('requires Python 2.7')
t1 = 5000000000.0
compile(f, (str, float))(str(fname), t1)
assert t1 == os.stat(str(fname)).st_mtime
+ @win_only
def test__getfullpathname(self):
- if os.name != 'nt':
- py.test.skip('nt specific function')
posix = __import__(os.name)
sysdrv = os.getenv('SystemDrive', 'C:')
stuff = sysdrv + 'stuff'
@@ -134,10 +131,8 @@
os.unlink(filename)
+ @py.test.mark.skipif("os.name != 'posix'")
def test_execve(self):
- if os.name != 'posix':
- py.test.skip('posix specific function')
-
EXECVE_ENV = {"foo": "bar", "baz": "quux"}
def run_execve(program, args=None, env=None, do_path_lookup=False):
@@ -276,11 +271,8 @@
assert rposix.isatty(-1) is False
+ at py.test.mark.skipif("not hasattr(os, 'ttyname')")
class TestOsExpect(ExpectTest):
- def setup_class(cls):
- if not hasattr(os, 'ttyname'):
- py.test.skip("no ttyname")
-
def test_ttyname(self):
def f():
import os
@@ -444,9 +436,8 @@
except Exception:
pass
+ @win_only
def test_is_valid_fd(self):
- if os.name != 'nt':
- py.test.skip('relevant for windows only')
assert rposix.is_valid_fd(0) == 1
fid = open(str(udir.join('validate_test.txt')), 'w')
fd = fid.fileno()
More information about the pypy-commit
mailing list