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