From 23f8093a2c65d4258a2d69f1b604fe7834b55fc7 Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Tue, 14 May 2024 01:14:43 +0900 Subject: [PATCH] ci: Set default port-range --- tests/test_javascript.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_javascript.py b/tests/test_javascript.py index e609456..6f41b94 100644 --- a/tests/test_javascript.py +++ b/tests/test_javascript.py @@ -19,8 +19,11 @@ def _is_port_in_use(self, port: int) -> bool: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: return s.connect_ex(("localhost", port)) == 0 - def __init__(self, directory: Path, port_range: Tuple[int, int]): - """Initialize server with found usable port.""" + def __init__(self, directory: Path, port_range: Tuple[int, int] = (49152, 60999)): + """Initialize server with found usable port. + + Default port-range is ephemeral ports. + """ self.directory = directory for v in range(port_range[0], port_range[1] + 1): if not self._is_port_in_use(v): @@ -55,7 +58,7 @@ def __exit__(self, *args, **kwargs): # noqa: D105 ) def test__root(app: SphinxTestApp, page: Page): app.build() - with ServerOnPytest(app.outdir, (30000, 50000)) as server: + with ServerOnPytest(app.outdir) as server: url = f"http://localhost:{server.port}/" page.goto(url) time.sleep(0.5)