]> jfr.im git - yt-dlp.git/blame - test/test_execution.py
[cleanup] Consistent style for file heads
[yt-dlp.git] / test / test_execution.py
CommitLineData
cc52de43 1#!/usr/bin/env python3
54007a45 2
3# Allow direct execution
e575b682 4import os
f8271158 5import sys
6import unittest
7
ff02a228
S
8sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
9
54007a45 10
11import contextlib
12import subprocess
13
7a5c1cfe 14from yt_dlp.utils import encodeArgument
e575b682
PH
15
16rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17
a0f59cdc 18
e575b682
PH
19try:
20 _DEV_NULL = subprocess.DEVNULL
21except AttributeError:
22 _DEV_NULL = open(os.devnull, 'wb')
23
a0f59cdc 24
e575b682
PH
25class TestExecution(unittest.TestCase):
26 def test_import(self):
7a5c1cfe 27 subprocess.check_call([sys.executable, '-c', 'import yt_dlp'], cwd=rootDir)
e575b682
PH
28
29 def test_module_exec(self):
19a03940 30 subprocess.check_call([sys.executable, '-m', 'yt_dlp', '--ignore-config', '--version'], cwd=rootDir, stdout=_DEV_NULL)
e575b682
PH
31
32 def test_main_exec(self):
19a03940 33 subprocess.check_call([sys.executable, 'yt_dlp/__main__.py', '--ignore-config', '--version'], cwd=rootDir, stdout=_DEV_NULL)
e575b682 34
f5e2efbb
PH
35 def test_cmdline_umlauts(self):
36 p = subprocess.Popen(
19a03940 37 [sys.executable, 'yt_dlp/__main__.py', '--ignore-config', encodeArgument('ä'), '--version'],
f5e2efbb
PH
38 cwd=rootDir, stdout=_DEV_NULL, stderr=subprocess.PIPE)
39 _, stderr = p.communicate()
40 self.assertFalse(stderr)
41
1bdae7d3 42 def test_lazy_extractors(self):
43 try:
44 subprocess.check_call([sys.executable, 'devscripts/make_lazy_extractors.py', 'yt_dlp/extractor/lazy_extractors.py'], cwd=rootDir, stdout=_DEV_NULL)
45 subprocess.check_call([sys.executable, 'test/test_all_urls.py'], cwd=rootDir, stdout=_DEV_NULL)
46 finally:
19a03940 47 with contextlib.suppress(OSError):
1bdae7d3 48 os.remove('yt_dlp/extractor/lazy_extractors.py')
1bdae7d3 49
582be358 50
e575b682
PH
51if __name__ == '__main__':
52 unittest.main()