]>
jfr.im git - yt-dlp.git/blob - test/test_execution.py
3 # Allow direct execution
8 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
14 from yt_dlp
.utils
import encodeArgument
16 rootDir
= os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
)))
20 _DEV_NULL
= subprocess
.DEVNULL
21 except AttributeError:
22 _DEV_NULL
= open(os
.devnull
, 'wb')
25 class TestExecution(unittest
.TestCase
):
26 def test_import(self
):
27 subprocess
.check_call([sys
.executable
, '-c', 'import yt_dlp'], cwd
=rootDir
)
29 def test_module_exec(self
):
30 subprocess
.check_call([sys
.executable
, '-m', 'yt_dlp', '--ignore-config', '--version'], cwd
=rootDir
, stdout
=_DEV_NULL
)
32 def test_main_exec(self
):
33 subprocess
.check_call([sys
.executable
, 'yt_dlp/__main__.py', '--ignore-config', '--version'], cwd
=rootDir
, stdout
=_DEV_NULL
)
35 def test_cmdline_umlauts(self
):
37 [sys
.executable
, 'yt_dlp/__main__.py', '--ignore-config', encodeArgument('รค'), '--version'],
38 cwd
=rootDir
, stdout
=_DEV_NULL
, stderr
=subprocess
.PIPE
)
39 _
, stderr
= p
.communicate()
40 self
.assertFalse(stderr
)
42 def test_lazy_extractors(self
):
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
)
47 with contextlib
.suppress(OSError):
48 os
.remove('yt_dlp/extractor/lazy_extractors.py')
51 if __name__
== '__main__':