]>
Commit | Line | Data |
---|---|---|
cc52de43 | 1 | #!/usr/bin/env python3 |
54007a45 | 2 | |
3 | # Allow direct execution | |
ce28252c | 4 | import os |
f8271158 | 5 | import sys |
6 | import unittest | |
7 | ||
ce28252c PH |
8 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
9 | ||
54007a45 | 10 | |
11 | import subprocess | |
12 | ||
ce28252c PH |
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 | [ | |
19a03940 | 20 | sys.executable, 'yt_dlp/__main__.py', |
21 | '-v', '--ignore-config', | |
ce28252c | 22 | '--username', 'johnsmith@gmail.com', |
f95a7b93 | 23 | '--password', 'my_secret_password', |
ce28252c PH |
24 | ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
25 | sout, serr = outp.communicate() | |
52aa7e74 YCH |
26 | self.assertTrue(b'--username' in serr) |
27 | self.assertTrue(b'johnsmith' not in serr) | |
28 | self.assertTrue(b'--password' in serr) | |
f95a7b93 | 29 | self.assertTrue(b'my_secret_password' not in serr) |
ce28252c PH |
30 | |
31 | def test_private_info_shortarg(self): | |
32 | outp = subprocess.Popen( | |
33 | [ | |
19a03940 | 34 | sys.executable, 'yt_dlp/__main__.py', |
35 | '-v', '--ignore-config', | |
ce28252c | 36 | '-u', 'johnsmith@gmail.com', |
f95a7b93 | 37 | '-p', 'my_secret_password', |
ce28252c PH |
38 | ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
39 | sout, serr = outp.communicate() | |
52aa7e74 YCH |
40 | self.assertTrue(b'-u' in serr) |
41 | self.assertTrue(b'johnsmith' not in serr) | |
42 | self.assertTrue(b'-p' in serr) | |
f95a7b93 | 43 | self.assertTrue(b'my_secret_password' not in serr) |
ce28252c PH |
44 | |
45 | def test_private_info_eq(self): | |
46 | outp = subprocess.Popen( | |
47 | [ | |
19a03940 | 48 | sys.executable, 'yt_dlp/__main__.py', |
49 | '-v', '--ignore-config', | |
ce28252c | 50 | '--username=johnsmith@gmail.com', |
f95a7b93 | 51 | '--password=my_secret_password', |
ce28252c PH |
52 | ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
53 | sout, serr = outp.communicate() | |
52aa7e74 YCH |
54 | self.assertTrue(b'--username' in serr) |
55 | self.assertTrue(b'johnsmith' not in serr) | |
56 | self.assertTrue(b'--password' in serr) | |
f95a7b93 | 57 | self.assertTrue(b'my_secret_password' not in serr) |
ce28252c PH |
58 | |
59 | def test_private_info_shortarg_eq(self): | |
60 | outp = subprocess.Popen( | |
61 | [ | |
19a03940 | 62 | sys.executable, 'yt_dlp/__main__.py', |
63 | '-v', '--ignore-config', | |
ce28252c | 64 | '-u=johnsmith@gmail.com', |
f95a7b93 | 65 | '-p=my_secret_password', |
ce28252c PH |
66 | ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
67 | sout, serr = outp.communicate() | |
52aa7e74 YCH |
68 | self.assertTrue(b'-u' in serr) |
69 | self.assertTrue(b'johnsmith' not in serr) | |
70 | self.assertTrue(b'-p' in serr) | |
f95a7b93 | 71 | self.assertTrue(b'my_secret_password' not in serr) |
ce28252c | 72 | |
582be358 | 73 | |
ce28252c PH |
74 | if __name__ == '__main__': |
75 | unittest.main() |