]> jfr.im git - yt-dlp.git/blame - test/test_execution.py
Credit @Roman2K for pornovoisines (#5264)
[yt-dlp.git] / test / test_execution.py
CommitLineData
a0f59cdc 1#!/usr/bin/env python
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
11
12rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
13
a0f59cdc 14
e575b682
PH
15try:
16 _DEV_NULL = subprocess.DEVNULL
17except AttributeError:
18 _DEV_NULL = open(os.devnull, 'wb')
19
a0f59cdc 20
e575b682
PH
21class TestExecution(unittest.TestCase):
22 def test_import(self):
23 subprocess.check_call([sys.executable, '-c', 'import youtube_dl'], cwd=rootDir)
24
25 def test_module_exec(self):
a0f59cdc 26 if sys.version_info >= (2, 7): # Python 2.6 doesn't support package execution
e575b682
PH
27 subprocess.check_call([sys.executable, '-m', 'youtube_dl', '--version'], cwd=rootDir, stdout=_DEV_NULL)
28
29 def test_main_exec(self):
30 subprocess.check_call([sys.executable, 'youtube_dl/__main__.py', '--version'], cwd=rootDir, stdout=_DEV_NULL)
31
f5e2efbb
PH
32 def test_cmdline_umlauts(self):
33 p = subprocess.Popen(
34 [sys.executable, 'youtube_dl/__main__.py', 'รค', '--version'],
35 cwd=rootDir, stdout=_DEV_NULL, stderr=subprocess.PIPE)
36 _, stderr = p.communicate()
37 self.assertFalse(stderr)
38
e575b682
PH
39if __name__ == '__main__':
40 unittest.main()