Repository: urllib3/urllib3

Issue:
flaky and pytest-memray incompatible
### Subject

```
______________________________________________________________________________________________________ TestHTTPProxyManager.test_forwarding_proxy_request_timeout[https-https-True] ______________________________________________________________________________________________________
Traceback (most recent call last):
  File "/home/graingert/projects/urllib3/.nox/test-3-11/lib/python3.11/site-packages/pytest_memray/plugin.py", line 122, in wrapper
    result: object | None = func(*args, **kwargs)
                            ^^^^^^^^^^^^^^^^^^^^^
  File "/home/graingert/projects/urllib3/.nox/test-3-11/lib/python3.11/site-packages/pytest_memray/plugin.py", line 121, in wrapper
    with Tracker(result_file):
  File "src/memray/_memray.pyx", line 404, in memray._memray.Tracker.__enter__
RuntimeError: No more than one Tracker instance can be active at the same time
```
caused by a flaky test:
```
===Flaky Test Report===

test_forwarding_proxy_request_timeout[https-https-True] failed (1 runs remaining out of 2).
    <class 'AssertionError'>
    assert <class 'urllib3.exceptions.ProxyError'> == ReadTimeoutError
 +  where <class 'urllib3.exceptions.ProxyError'> = type(ProxyError('Unable to connect to proxy', ReadTimeoutError("HTTPSConnectionPool(host='240.0.0.0', port=443): Read timed out. (read timeout=0.01)")))
 +    where ProxyError('Unable to connect to proxy', ReadTimeoutError("HTTPSConnectionPool(host='240.0.0.0', port=443): Read timed out. (read timeout=0.01)")) = MaxRetryError('HTTPSConnectionPool(host=\'240.0.0.0\', port=443): Max retries exceeded with url: https://240.0.0.0 (Caused by ProxyError(\'Unable to connect to proxy\', ReadTimeoutError("HTTPSConnectionPool(host=\'240.0.0.0\', port=443): Read timed out. (read timeout=0.01)")))').reason
 +      where MaxRetryError('HTTPSConnectionPool(host=\'240.0.0.0\', port=443): Max retries exceeded with url: https://240.0.0.0 (Caused by ProxyError(\'Unable to connect to proxy\', ReadTimeoutError("HTTPSConnectionPool(host=\'240.0.0.0\', port=443): Read timed out. (read timeout=0.01)")))') = <ExceptionInfo MaxRetryError('HTTPSConnectionPool(host=\'240.0.0.0\', port=443): Max retries exceeded with url: https://240.0.0.0 (Ca...proxy\', ReadTimeoutError("HTTPSConnectionPool(host=\'240.0.0.0\', port=443): Read timed out. (read timeout=0.01)")))') tblen=10>.value
    [<TracebackEntry /home/graingert/projects/urllib3/test/with_dummyserver/test_proxy_poolmanager.py:484>]
test_forwarding_proxy_request_timeout[https-https-True] failed; it passed 0 out of the required 1 times.
    <class 'RuntimeError'>
    No more than one Tracker instance can be active at the same time
    [<TracebackEntry /home/graingert/projects/urllib3/.nox/test-3-11/lib/python3.11/site-packages/pytest_memray/plugin.py:122>, <TracebackEntry /home/graingert/projects/urllib3/.nox/test-3-11/lib/python3.11/site-packages/pytest_memray/plugin.py:121>, <TracebackEntry src/memray/_memray.pyx:404>]

```

see also https://github.com/bloomberg/pytest-memray/issues/53



Discussion:

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -56,7 +56,6 @@ def tests_impl(
         "-ra",
         f"--color={'yes' if 'GITHUB_ACTIONS' in os.environ else 'auto'}",
         "--tb=native",
-        "--no-success-flaky-report",
         "--durations=10",
         "--strict-config",
         "--strict-markers",


Test patch:
diff --git a/test/with_dummyserver/test_chunked_transfer.py b/test/with_dummyserver/test_chunked_transfer.py
--- a/test/with_dummyserver/test_chunked_transfer.py
+++ b/test/with_dummyserver/test_chunked_transfer.py
@@ -13,9 +13,6 @@
 from urllib3.util import SKIP_HEADER
 from urllib3.util.retry import Retry
 
-# Retry failed tests
-pytestmark = pytest.mark.flaky
-
 
 class TestChunkedTransfer(SocketDummyServerTestCase):
     def start_chunked_handler(self) -> None:
diff --git a/test/with_dummyserver/test_connectionpool.py b/test/with_dummyserver/test_connectionpool.py
--- a/test/with_dummyserver/test_connectionpool.py
+++ b/test/with_dummyserver/test_connectionpool.py
@@ -35,8 +35,6 @@
 from .. import INVALID_SOURCE_ADDRESSES, TARPIT_HOST, VALID_SOURCE_ADDRESSES
 from ..port_helpers import find_unused_port
 
-pytestmark = pytest.mark.flaky
-
 
 def wait_for_socket(ready_event: Event) -> None:
     ready_event.wait()
diff --git a/test/with_dummyserver/test_https.py b/test/with_dummyserver/test_https.py
--- a/test/with_dummyserver/test_https.py
+++ b/test/with_dummyserver/test_https.py
@@ -47,10 +47,6 @@
 
 from .. import has_alpn
 
-# Retry failed tests
-pytestmark = pytest.mark.flaky
-
-
 TLSv1_CERTS = DEFAULT_CERTS.copy()
 TLSv1_CERTS["ssl_version"] = getattr(ssl, "PROTOCOL_TLSv1", None)
 
diff --git a/test/with_dummyserver/test_no_ssl.py b/test/with_dummyserver/test_no_ssl.py
--- a/test/with_dummyserver/test_no_ssl.py
+++ b/test/with_dummyserver/test_no_ssl.py
@@ -5,16 +5,11 @@
 """
 from __future__ import annotations
 
-import pytest
-
 import urllib3
 from dummyserver.testcase import HTTPDummyServerTestCase, HTTPSDummyServerTestCase
 
 from ..test_no_ssl import TestWithoutSSL
 
-# Retry failed tests
-pytestmark = pytest.mark.flaky
-
 
 class TestHTTPWithoutSSL(HTTPDummyServerTestCase, TestWithoutSSL):
     def test_simple(self) -> None:
diff --git a/test/with_dummyserver/test_poolmanager.py b/test/with_dummyserver/test_poolmanager.py
--- a/test/with_dummyserver/test_poolmanager.py
+++ b/test/with_dummyserver/test_poolmanager.py
@@ -14,9 +14,6 @@
 from urllib3.poolmanager import PoolManager
 from urllib3.util.retry import Retry
 
-# Retry failed tests
-pytestmark = pytest.mark.flaky
-
 
 class TestPoolManager(HTTPDummyServerTestCase):
     @classmethod
diff --git a/test/with_dummyserver/test_proxy_poolmanager.py b/test/with_dummyserver/test_proxy_poolmanager.py
--- a/test/with_dummyserver/test_proxy_poolmanager.py
+++ b/test/with_dummyserver/test_proxy_poolmanager.py
@@ -37,9 +37,6 @@
 
 from .. import TARPIT_HOST, requires_network
 
-# Retry failed tests
-pytestmark = pytest.mark.flaky
-
 
 class TestHTTPProxyManager(HTTPDummyProxyTestCase):
     @classmethod
diff --git a/test/with_dummyserver/test_socketlevel.py b/test/with_dummyserver/test_socketlevel.py
--- a/test/with_dummyserver/test_socketlevel.py
+++ b/test/with_dummyserver/test_socketlevel.py
@@ -60,9 +60,6 @@
 else:
     StrOrBytesPath = object
 
-# Retry failed tests
-pytestmark = pytest.mark.flaky
-
 
 class TestCookies(SocketDummyServerTestCase):
     def test_multi_setcookie(self) -> None: