From 69d31914952dd33082ac7019c6f76b43c45b9d06 Mon Sep 17 00:00:00 2001 From: coletdjnz Date: Sat, 20 Jan 2024 10:39:49 +1300 Subject: [test] Skip source address tests if the address cannot be bound to (#8900) Fixes https://github.com/yt-dlp/yt-dlp/issues/8890 Authored by: coletdjnz --- test/test_networking.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'test/test_networking.py') diff --git a/test/test_networking.py b/test/test_networking.py index dc60ca699..62325aa8e 100644 --- a/test/test_networking.py +++ b/test/test_networking.py @@ -26,7 +26,7 @@ import zlib from email.message import Message from http.cookiejar import CookieJar -from test.helper import FakeYDL, http_server_port +from test.helper import FakeYDL, http_server_port, verify_address_availability from yt_dlp.cookies import YoutubeDLCookieJar from yt_dlp.dependencies import brotli, requests, urllib3 from yt_dlp.networking import ( @@ -538,6 +538,9 @@ class TestHTTPRequestHandler(TestRequestHandlerBase): @pytest.mark.parametrize('handler', ['Urllib', 'Requests'], indirect=True) def test_source_address(self, handler): source_address = f'127.0.0.{random.randint(5, 255)}' + # on some systems these loopback addresses we need for testing may not be available + # see: https://github.com/yt-dlp/yt-dlp/issues/8890 + verify_address_availability(source_address) with handler(source_address=source_address) as rh: data = validate_and_send( rh, Request(f'http://127.0.0.1:{self.http_port}/source_address')).read().decode() -- cgit v1.2.3