[tests] replace 'print' with 'sys.stdout.write'

This commit is contained in:
Mike Fährmann
2025-06-17 22:05:41 +02:00
parent dd299b3dad
commit f7b1b6b5c8
2 changed files with 5 additions and 5 deletions

View File

@@ -122,7 +122,7 @@ class TestExtractorModule(unittest.TestCase):
extr = cls.from_url(url)
except ImportError as exc:
if exc.name in ("youtube_dl", "yt_dlp"):
print("Skipping '{}' category checks".format(cls.category))
sys.stdout.write(f"Skipping '{cls.category}' category checks")
return
raise
self.assertTrue(extr, url)

View File

@@ -80,9 +80,9 @@ class TestExtractorResults(unittest.TestCase):
@classmethod
def tearDownClass(cls):
if cls._skipped:
print("\n\nSkipped tests:")
for url, exc in cls._skipped:
print('- {} ("{}")'.format(url, exc))
sys.stdout.write("\n\nSkipped tests:\n")
for url, reason in cls._skipped:
sys.stdout.write(f'- {url} ("{reason}")\n')
def assertRange(self, value, range, msg=None):
if range.step > 1:
@@ -503,7 +503,7 @@ def generate_tests():
"""Dynamically generate extractor unittests"""
def _generate_method(result):
def test(self):
print("\n" + result["#url"])
sys.stdout.write(f"\n{result['#url']}\n")
try:
self._run_test(result)
except KeyboardInterrupt as exc: