From 602f54087387beef30e373ebd866b49b33eeeaaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionel=20Cristian=20M=C4=83rie=C8=99?= Date: Mon, 18 Dec 2023 15:44:08 +0200 Subject: [PATCH] Fix some test issues. --- tests/test_manhole.py | 26 +++++++++++++------------- tests/test_manhole_cli.py | 3 +-- tox.ini | 7 +++---- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/tests/test_manhole.py b/tests/test_manhole.py index 8f6ddf2..6dc1d69 100644 --- a/tests/test_manhole.py +++ b/tests/test_manhole.py @@ -1,4 +1,4 @@ -import imp +import importlib.util import os import re import select @@ -27,7 +27,7 @@ def is_lib_available(lib): def is_module_available(mod): try: - return imp.find_module(mod) + return importlib.util.find_spec(mod) except ImportError: return False @@ -85,7 +85,7 @@ def test_simple(): uds_path = re.findall(r'(/tmp/manhole-\d+)', proc.read())[0] wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') for _ in range(20): - proc.reset() + proc.buff.reset() assert_manhole_running(proc, uds_path) @@ -97,7 +97,7 @@ def test_connection_handler_exec(variant): uds_path = re.findall(r'(/tmp/manhole-\d+)', proc.read())[0] wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') for _ in range(200): - proc.reset() + proc.buff.reset() sock = connect_to_manhole(uds_path) wait_for_strings( proc.read, @@ -183,7 +183,7 @@ def test_locals_after_fork(): with TestProcess(sys.executable, HELPER, 'test_locals_after_fork') as proc: with dump_on_error(proc.read): wait_for_strings(proc.read, TIMEOUT, 'Fork detected') - proc.reset() + proc.buff.reset() wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-') child_uds_path = re.findall(r'(/tmp/manhole-\d+)', proc.read())[0] wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') @@ -209,7 +209,7 @@ def test_socket_path(): with TestProcess(sys.executable, HELPER, 'test_socket_path') as proc: with dump_on_error(proc.read): wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') - proc.reset() + proc.buff.reset() assert_manhole_running(proc, SOCKET_PATH) @@ -343,10 +343,10 @@ def test_with_fork(): uds_path = re.findall(r'(/tmp/manhole-\d+)', proc.read())[0] wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') for _ in range(2): - proc.reset() + proc.buff.reset() assert_manhole_running(proc, uds_path) - proc.reset() + proc.buff.reset() wait_for_strings(proc.read, TIMEOUT, 'Fork detected') wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-') new_uds_path = re.findall(r'(/tmp/manhole-\d+)', proc.read())[0] @@ -354,7 +354,7 @@ def test_with_fork(): wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') for _ in range(2): - proc.reset() + proc.buff.reset() assert_manhole_running(proc, new_uds_path) @@ -365,10 +365,10 @@ def test_with_forkpty(): uds_path = re.findall(r'(/tmp/manhole-\d+)', proc.read())[0] wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') for _ in range(2): - proc.reset() + proc.buff.reset() assert_manhole_running(proc, uds_path) - proc.reset() + proc.buff.reset() wait_for_strings(proc.read, TIMEOUT, 'Fork detected') wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-') new_uds_path = re.findall(r'(/tmp/manhole-\d+)', proc.read())[0] @@ -376,7 +376,7 @@ def test_with_forkpty(): wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') for _ in range(2): - proc.reset() + proc.buff.reset() assert_manhole_running(proc, new_uds_path) @@ -469,7 +469,7 @@ def test_oneshot_on_usr2_error(): wait_for_strings(proc.read, TIMEOUT, 'Waiting for new connection') assert_manhole_running(proc, uds_path, oneshot=True, extra=lambda client: client.sock.send(b'raise SystemExit()\n')) - proc.reset() + proc.buff.reset() proc.signal(signal.SIGUSR2) wait_for_strings(proc.read, TIMEOUT, '/tmp/manhole-') uds_path = re.findall(r'(/tmp/manhole-\d+)', proc.read())[0] diff --git a/tests/test_manhole_cli.py b/tests/test_manhole_cli.py index 88aba41..4ae032e 100644 --- a/tests/test_manhole_cli.py +++ b/tests/test_manhole_cli.py @@ -45,8 +45,7 @@ def test_help(testdir): 'usage: manhole-cli [-h] [-t TIMEOUT] [-1 | -2 | -s SIGNAL] PID', 'Connect to a manhole.', 'positional arguments:', - ' PID A numerical process id, or a path in the form:', - ' /tmp/manhole-1234', + ' PID A numerical process id, or a path in the form:*', 'optional arguments:', ' -h, --help show this help message and exit', ' -t TIMEOUT, --timeout TIMEOUT', diff --git a/tox.ini b/tox.ini index a15cfaa..7a854f9 100644 --- a/tox.ini +++ b/tox.ini @@ -42,10 +42,9 @@ deps = cover: pytest-cov requests process-tests - py27: subprocess32 - eventlet: eventlet==0.30.2 - gevent: gevent==21.1.2 - {py27,py36,py37,py38,py39,py310}: uwsgi==2.0.20 + eventlet: eventlet==0.33.3 + gevent: gevent==23.9.1 + {py27,py36,py37,py38,py39,py310,py311,py312}: uwsgi==2.0.23 commands = nocov: {posargs:pytest -vv --ignore=src} cover: {posargs:pytest --cov --cov-report=term-missing --cov-report=xml -vv}