]> jfr.im git - yt-dlp.git/blob - test/test_execution.py
[compat] Remove more functions
[yt-dlp.git] / test / test_execution.py
1 #!/usr/bin/env python3
2 import contextlib
3 import os
4 import subprocess
5 import sys
6 import unittest
7
8 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
9
10 from yt_dlp.utils import encodeArgument
11
12 rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
13
14
15 try:
16 _DEV_NULL = subprocess.DEVNULL
17 except AttributeError:
18 _DEV_NULL = open(os.devnull, 'wb')
19
20
21 class TestExecution(unittest.TestCase):
22 def test_import(self):
23 subprocess.check_call([sys.executable, '-c', 'import yt_dlp'], cwd=rootDir)
24
25 def test_module_exec(self):
26 subprocess.check_call([sys.executable, '-m', 'yt_dlp', '--ignore-config', '--version'], cwd=rootDir, stdout=_DEV_NULL)
27
28 def test_main_exec(self):
29 subprocess.check_call([sys.executable, 'yt_dlp/__main__.py', '--ignore-config', '--version'], cwd=rootDir, stdout=_DEV_NULL)
30
31 def test_cmdline_umlauts(self):
32 p = subprocess.Popen(
33 [sys.executable, 'yt_dlp/__main__.py', '--ignore-config', encodeArgument('รค'), '--version'],
34 cwd=rootDir, stdout=_DEV_NULL, stderr=subprocess.PIPE)
35 _, stderr = p.communicate()
36 self.assertFalse(stderr)
37
38 def test_lazy_extractors(self):
39 try:
40 subprocess.check_call([sys.executable, 'devscripts/make_lazy_extractors.py', 'yt_dlp/extractor/lazy_extractors.py'], cwd=rootDir, stdout=_DEV_NULL)
41 subprocess.check_call([sys.executable, 'test/test_all_urls.py'], cwd=rootDir, stdout=_DEV_NULL)
42 finally:
43 with contextlib.suppress(OSError):
44 os.remove('yt_dlp/extractor/lazy_extractors.py')
45
46
47 if __name__ == '__main__':
48 unittest.main()