From 27fe903c511691c078942bef5ee9a05a43b15c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Wed, 9 Jun 2021 17:54:27 -0500 Subject: initial --- test/test_execution.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 test/test_execution.py (limited to 'test/test_execution.py') diff --git a/test/test_execution.py b/test/test_execution.py new file mode 100644 index 0000000..f049551 --- /dev/null +++ b/test/test_execution.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# coding: utf-8 + +from __future__ import unicode_literals + +import unittest + +import sys +import os +import subprocess +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from hypervideo_dl.utils import encodeArgument + +rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +try: + _DEV_NULL = subprocess.DEVNULL +except AttributeError: + _DEV_NULL = open(os.devnull, 'wb') + + +class TestExecution(unittest.TestCase): + def test_import(self): + subprocess.check_call([sys.executable, '-c', 'import hypervideo_dl'], cwd=rootDir) + + def test_module_exec(self): + if sys.version_info >= (2, 7): # Python 2.6 doesn't support package execution + subprocess.check_call([sys.executable, '-m', 'hypervideo_dl', '--version'], cwd=rootDir, stdout=_DEV_NULL) + + def test_main_exec(self): + subprocess.check_call([sys.executable, 'hypervideo_dl/__main__.py', '--version'], cwd=rootDir, stdout=_DEV_NULL) + + def test_cmdline_umlauts(self): + p = subprocess.Popen( + [sys.executable, 'hypervideo_dl/__main__.py', encodeArgument('รค'), '--version'], + cwd=rootDir, stdout=_DEV_NULL, stderr=subprocess.PIPE) + _, stderr = p.communicate() + self.assertFalse(stderr) + + def test_lazy_extractors(self): + try: + subprocess.check_call([sys.executable, 'devscripts/make_lazy_extractors.py', 'hypervideo_dl/extractor/lazy_extractors.py'], cwd=rootDir, stdout=_DEV_NULL) + subprocess.check_call([sys.executable, 'test/test_all_urls.py'], cwd=rootDir, stdout=_DEV_NULL) + finally: + try: + os.remove('hypervideo_dl/extractor/lazy_extractors.py') + except (IOError, OSError): + pass + + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3