]> jfr.im git - yt-dlp.git/blame - test/test_execution.py
[skip travis] renaming
[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
ff02a228
S
11sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
12
cefecac1 13from youtube_dlc.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):
cefecac1 26 subprocess.check_call([sys.executable, '-c', 'import youtube_dlc'], cwd=rootDir)
e575b682
PH
27
28 def test_module_exec(self):
a0f59cdc 29 if sys.version_info >= (2, 7): # Python 2.6 doesn't support package execution
cefecac1 30 subprocess.check_call([sys.executable, '-m', 'youtube_dlc', '--version'], cwd=rootDir, stdout=_DEV_NULL)
e575b682
PH
31
32 def test_main_exec(self):
cefecac1 33 subprocess.check_call([sys.executable, 'youtube_dlc/__main__.py', '--version'], cwd=rootDir, stdout=_DEV_NULL)
e575b682 34
f5e2efbb
PH
35 def test_cmdline_umlauts(self):
36 p = subprocess.Popen(
cefecac1 37 [sys.executable, 'youtube_dlc/__main__.py', encodeArgument('ä'), '--version'],
f5e2efbb
PH
38 cwd=rootDir, stdout=_DEV_NULL, stderr=subprocess.PIPE)
39 _, stderr = p.communicate()
40 self.assertFalse(stderr)
41
582be358 42
e575b682
PH
43if __name__ == '__main__':
44 unittest.main()