]> gitweb @ CieloNegro.org - youtube-dl.git/blob - test/test_verbose_output.py
[sohu] Update _TESTS (closes #10260)
[youtube-dl.git] / test / test_verbose_output.py
1 #!/usr/bin/env python
2 # coding: utf-8
3
4 from __future__ import unicode_literals
5
6 import unittest
7
8 import sys
9 import os
10 import subprocess
11 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
12
13 rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
14
15
16 class TestVerboseOutput(unittest.TestCase):
17     def test_private_info_arg(self):
18         outp = subprocess.Popen(
19             [
20                 sys.executable, 'youtube_dl/__main__.py', '-v',
21                 '--username', 'johnsmith@gmail.com',
22                 '--password', 'secret',
23             ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
24         sout, serr = outp.communicate()
25         self.assertTrue('--username' in serr)
26         self.assertTrue('johnsmith' not in serr)
27         self.assertTrue('--password' in serr)
28         self.assertTrue('secret' not in serr)
29
30     def test_private_info_shortarg(self):
31         outp = subprocess.Popen(
32             [
33                 sys.executable, 'youtube_dl/__main__.py', '-v',
34                 '-u', 'johnsmith@gmail.com',
35                 '-p', 'secret',
36             ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
37         sout, serr = outp.communicate()
38         self.assertTrue('-u' in serr)
39         self.assertTrue('johnsmith' not in serr)
40         self.assertTrue('-p' in serr)
41         self.assertTrue('secret' not in serr)
42
43     def test_private_info_eq(self):
44         outp = subprocess.Popen(
45             [
46                 sys.executable, 'youtube_dl/__main__.py', '-v',
47                 '--username=johnsmith@gmail.com',
48                 '--password=secret',
49             ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
50         sout, serr = outp.communicate()
51         self.assertTrue('--username' in serr)
52         self.assertTrue('johnsmith' not in serr)
53         self.assertTrue('--password' in serr)
54         self.assertTrue('secret' not in serr)
55
56     def test_private_info_shortarg_eq(self):
57         outp = subprocess.Popen(
58             [
59                 sys.executable, 'youtube_dl/__main__.py', '-v',
60                 '-u=johnsmith@gmail.com',
61                 '-p=secret',
62             ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
63         sout, serr = outp.communicate()
64         self.assertTrue('-u' in serr)
65         self.assertTrue('johnsmith' not in serr)
66         self.assertTrue('-p' in serr)
67         self.assertTrue('secret' not in serr)
68
69 if __name__ == '__main__':
70     unittest.main()