Rewrite test_safe_wait_INADDR_ANY in pure pytest
import os
import signal
import time
-import unittest
from http.client import BadStatusLine
import pytest
@@ -431,9 +430,7 @@ test_case_name: "test_signal_handler_unsubscribe"
)
-class WaitTests(unittest.TestCase):
-
- def test_safe_wait_INADDR_ANY(self):
+def test_safe_wait_INADDR_ANY(): # pylint: disable=invalid-name
"""
Wait on INADDR_ANY should not raise IOError
@@ -459,13 +456,15 @@ class WaitTests(unittest.TestCase):
with pytest.warns(
UserWarning,
match='Unable to verify that the server is bound on ',
- ) as w:
+ ) as warnings:
+ # pylint: disable=protected-access
with servers._safe_wait(inaddr_any, free_port):
portend.occupied(inaddr_any, free_port, timeout=1)
- assert len(w) == 1
+ assert len(warnings) == 1
# The wait should still raise an IO error if INADDR_ANY was
# not supplied.
with pytest.raises(IOError):
+ # pylint: disable=protected-access
with servers._safe_wait('127.0.0.1', free_port):
portend.occupied('127.0.0.1', free_port, timeout=1)
