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