From e6e71285b9e0ed0925ae459e951dcf2f55df4d17 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 30 Oct 2023 10:29:57 +0100 Subject: [PATCH] test: PyPy fixes On PyPy 3.9 `sock.close()` sometimes fails with `Bad file descriptor`, because the fd is already closed. Silence the exception. The problem is not a bug in python-ldap. Really use PyPy 3.9 in `tox.ini`. Signed-off-by: Christian Heimes --- Tests/t_ldapobject.py | 6 +++++- tox.ini | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Tests/t_ldapobject.py b/Tests/t_ldapobject.py index ccc7d218..c26b317c 100644 --- a/Tests/t_ldapobject.py +++ b/Tests/t_ldapobject.py @@ -657,7 +657,11 @@ def _open_ldap_conn(self, who=None, cred=None, **kwargs): ) def tearDown(self): - self._sock.close() + try: + self._sock.close() + except OSError: + # PyPy sometimes fails with "Bad file descriptor" + pass delattr(self, '_sock') super().tearDown() diff --git a/tox.ini b/tox.ini index beade024..5907fbca 100644 --- a/tox.ini +++ b/tox.ini @@ -86,8 +86,8 @@ commands = Tests/t_ldif.py \ Tests/t_untested_mods.py -[testenv:pypy3] -basepython = pypy3 +[testenv:pypy3.9] +basepython = pypy3.9 deps = pytest commands = {envpython} -m pytest {posargs}