|
9 | 9 |
|
10 | 10 |
|
11 | 11 | @pytest.mark.skipif(IS_PYPY, reason="gc.DEBUG_LEAK not available on PyPy")
|
12 |
| -def test_client_response_does_not_leak_on_server_disconnected_error() -> None: |
13 |
| - """Test that ClientResponse is collected after server disconnects. |
14 |
| -
|
15 |
| - https://github.com/aio-libs/aiohttp/issues/10535 |
16 |
| - """ |
17 |
| - leak_test_script = pathlib.Path(__file__).parent.joinpath( |
18 |
| - "isolated", "check_for_client_response_leak.py" |
19 |
| - ) |
20 |
| - |
21 |
| - with subprocess.Popen( |
22 |
| - [sys.executable, "-u", str(leak_test_script)], |
23 |
| - stdout=subprocess.PIPE, |
24 |
| - ) as proc: |
25 |
| - assert proc.wait() == 0, "ClientResponse leaked" |
26 |
| - |
27 |
| - |
28 |
| -@pytest.mark.skipif(IS_PYPY, reason="gc.DEBUG_LEAK not available on PyPy") |
29 |
| -def test_request_does_not_leak_when_request_handler_raises() -> None: |
30 |
| - """Test that the Request object is collected when the handler raises. |
31 |
| -
|
32 |
| - https://github.com/aio-libs/aiohttp/issues/10548 |
33 |
| - """ |
34 |
| - leak_test_script = pathlib.Path(__file__).parent.joinpath( |
35 |
| - "isolated", "check_for_request_leak.py" |
36 |
| - ) |
| 12 | +@pytest.mark.parametrize( |
| 13 | + ("script", "message"), |
| 14 | + [ |
| 15 | + ( |
| 16 | + # Test that ClientResponse is collected after server disconnects. |
| 17 | + # https://github.com/aio-libs/aiohttp/issues/10535 |
| 18 | + "check_for_client_response_leak.py", |
| 19 | + "ClientResponse leaked", |
| 20 | + ), |
| 21 | + ( |
| 22 | + # Test that Request object is collected when the handler raises. |
| 23 | + # https://github.com/aio-libs/aiohttp/issues/10548 |
| 24 | + "check_for_request_leak.py", |
| 25 | + "Request leaked", |
| 26 | + ), |
| 27 | + ], |
| 28 | +) |
| 29 | +def test_leak(script: str, message: str) -> None: |
| 30 | + """Run isolated leak test script and check for leaks.""" |
| 31 | + leak_test_script = pathlib.Path(__file__).parent.joinpath("isolated", script) |
37 | 32 |
|
38 | 33 | with subprocess.Popen(
|
39 | 34 | [sys.executable, "-u", str(leak_test_script)],
|
40 | 35 | stdout=subprocess.PIPE,
|
41 | 36 | ) as proc:
|
42 |
| - assert proc.wait() == 0, "Request leaked" |
| 37 | + assert proc.wait() == 0, message |
0 commit comments