diff --git a/py/_error.py b/py/_error.py index 2f1d9e3a0..bd183e0db 100644 --- a/py/_error.py +++ b/py/_error.py @@ -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: diff --git a/testing/root/test_error.py b/testing/root/test_error.py index 2450b171f..1b9cf70ef 100644 --- a/testing/root/test_error.py +++ b/testing/root/test_error.py @@ -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))