diff options
| author | Armin Rigo <arigo@tunes.org> | 2021-06-20 20:31:53 +0200 |
|---|---|---|
| committer | Armin Rigo <arigo@tunes.org> | 2021-06-20 20:31:53 +0200 |
| commit | 1d2de7dc29904d571069b947d3ec0d5b5dbed19c (patch) | |
| tree | e8c1635762dd410216a4bb487ac4c3dd2586db94 /testing/cffi0 | |
| parent | 1531a5c0c27cbc8c17bb721b936899c9ce24f329 (diff) | |
| download | cffi-1d2de7dc29904d571069b947d3ec0d5b5dbed19c.tar.gz | |
fix tests for py.test running on CPython v3.10.0b3
Diffstat (limited to 'testing/cffi0')
| -rw-r--r-- | testing/cffi0/test_function.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/testing/cffi0/test_function.py b/testing/cffi0/test_function.py index 4f2c864..b4bb23d 100644 --- a/testing/cffi0/test_function.py +++ b/testing/cffi0/test_function.py @@ -5,7 +5,7 @@ import math, os, sys import ctypes.util from cffi.backend_ctypes import CTypesBackend from testing.udir import udir -from testing.support import FdWriteCapture +from testing.support import FdWriteCapture, StdErrCapture from .backend_tests import needs_dlopen_none try: @@ -227,13 +227,9 @@ class TestFunction(object): def cb(): return returnvalue fptr = ffi.callback("void(*)(void)", cb) - old_stderr = sys.stderr - try: - sys.stderr = StringIO() + with StdErrCapture() as f: returned = fptr() - printed = sys.stderr.getvalue() - finally: - sys.stderr = old_stderr + printed = f.getvalue() assert returned is None if returnvalue is None: assert printed == '' |
