add kwarg support to py.errpr.checked_call

--HG--
branch : trunk
This commit is contained in:
Ronny Pfannschmidt 2010-06-03 10:21:48 +02:00
parent 75d80ca183
commit a07e494554
2 changed files with 7 additions and 2 deletions

View File

@ -53,11 +53,11 @@ class ErrorMaker(object):
self._errno2class[eno] = errorcls
return errorcls
def checked_call(self, func, *args):
def checked_call(self, func, *args, **kwargs):
""" call a function and raise an errno-exception if applicable. """
__tracebackhide__ = True
try:
return func(*args)
return func(*args, **kwargs)
except self.Error:
raise
except EnvironmentError:

View File

@ -24,3 +24,8 @@ def test_error_conversion_ENOTDIR(testdir):
assert isinstance(excinfo.value, EnvironmentError)
assert isinstance(excinfo.value, py.error.Error)
assert "ENOTDIR" in repr(excinfo.value)
def test_checked_call_supports_kwargs(tmpdir):
import tempfile
py.error.checked_call(tempfile.mkdtemp, dir=str(tmpdir))