You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. #!/usr/bin/env python
  2. # coding: utf-8
  3. from __future__ import unicode_literals
  4. import unittest
  5. import sys
  6. import os
  7. import subprocess
  8. rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  9. try:
  10. _DEV_NULL = subprocess.DEVNULL
  11. except AttributeError:
  12. _DEV_NULL = open(os.devnull, 'wb')
  13. class TestExecution(unittest.TestCase):
  14. def test_import(self):
  15. subprocess.check_call([sys.executable, '-c', 'import youtube_dl'], cwd=rootDir)
  16. def test_module_exec(self):
  17. if sys.version_info >= (2, 7): # Python 2.6 doesn't support package execution
  18. subprocess.check_call([sys.executable, '-m', 'youtube_dl', '--version'], cwd=rootDir, stdout=_DEV_NULL)
  19. def test_main_exec(self):
  20. subprocess.check_call([sys.executable, 'youtube_dl/__main__.py', '--version'], cwd=rootDir, stdout=_DEV_NULL)
  21. def test_cmdline_umlauts(self):
  22. p = subprocess.Popen(
  23. [sys.executable, 'youtube_dl/__main__.py', 'ä', '--version'],
  24. cwd=rootDir, stdout=_DEV_NULL, stderr=subprocess.PIPE)
  25. _, stderr = p.communicate()
  26. self.assertFalse(stderr)
  27. if __name__ == '__main__':
  28. unittest.main()