2021-06-03 09:43:42 +00:00
|
|
|
#!/usr/bin/env python3
|
2016-08-02 15:03:46 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
|
|
|
|
rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
|
|
|
|
|
|
class TestVerboseOutput(unittest.TestCase):
|
|
|
|
def test_private_info_arg(self):
|
|
|
|
outp = subprocess.Popen(
|
|
|
|
[
|
2021-02-24 18:45:56 +00:00
|
|
|
sys.executable, 'yt_dlp/__main__.py', '-v',
|
2016-08-02 15:03:46 +00:00
|
|
|
'--username', 'johnsmith@gmail.com',
|
2022-01-09 13:57:06 +00:00
|
|
|
'--password', 'my_secret_password',
|
2016-08-02 15:03:46 +00:00
|
|
|
], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
sout, serr = outp.communicate()
|
2016-08-13 09:36:14 +00:00
|
|
|
self.assertTrue(b'--username' in serr)
|
|
|
|
self.assertTrue(b'johnsmith' not in serr)
|
|
|
|
self.assertTrue(b'--password' in serr)
|
2022-01-09 13:57:06 +00:00
|
|
|
self.assertTrue(b'my_secret_password' not in serr)
|
2016-08-02 15:03:46 +00:00
|
|
|
|
|
|
|
def test_private_info_shortarg(self):
|
|
|
|
outp = subprocess.Popen(
|
|
|
|
[
|
2021-02-24 18:45:56 +00:00
|
|
|
sys.executable, 'yt_dlp/__main__.py', '-v',
|
2016-08-02 15:03:46 +00:00
|
|
|
'-u', 'johnsmith@gmail.com',
|
2022-01-09 13:57:06 +00:00
|
|
|
'-p', 'my_secret_password',
|
2016-08-02 15:03:46 +00:00
|
|
|
], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
sout, serr = outp.communicate()
|
2016-08-13 09:36:14 +00:00
|
|
|
self.assertTrue(b'-u' in serr)
|
|
|
|
self.assertTrue(b'johnsmith' not in serr)
|
|
|
|
self.assertTrue(b'-p' in serr)
|
2022-01-09 13:57:06 +00:00
|
|
|
self.assertTrue(b'my_secret_password' not in serr)
|
2016-08-02 15:03:46 +00:00
|
|
|
|
|
|
|
def test_private_info_eq(self):
|
|
|
|
outp = subprocess.Popen(
|
|
|
|
[
|
2021-02-24 18:45:56 +00:00
|
|
|
sys.executable, 'yt_dlp/__main__.py', '-v',
|
2016-08-02 15:03:46 +00:00
|
|
|
'--username=johnsmith@gmail.com',
|
2022-01-09 13:57:06 +00:00
|
|
|
'--password=my_secret_password',
|
2016-08-02 15:03:46 +00:00
|
|
|
], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
sout, serr = outp.communicate()
|
2016-08-13 09:36:14 +00:00
|
|
|
self.assertTrue(b'--username' in serr)
|
|
|
|
self.assertTrue(b'johnsmith' not in serr)
|
|
|
|
self.assertTrue(b'--password' in serr)
|
2022-01-09 13:57:06 +00:00
|
|
|
self.assertTrue(b'my_secret_password' not in serr)
|
2016-08-02 15:03:46 +00:00
|
|
|
|
|
|
|
def test_private_info_shortarg_eq(self):
|
|
|
|
outp = subprocess.Popen(
|
|
|
|
[
|
2021-02-24 18:45:56 +00:00
|
|
|
sys.executable, 'yt_dlp/__main__.py', '-v',
|
2016-08-02 15:03:46 +00:00
|
|
|
'-u=johnsmith@gmail.com',
|
2022-01-09 13:57:06 +00:00
|
|
|
'-p=my_secret_password',
|
2016-08-02 15:03:46 +00:00
|
|
|
], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
sout, serr = outp.communicate()
|
2016-08-13 09:36:14 +00:00
|
|
|
self.assertTrue(b'-u' in serr)
|
|
|
|
self.assertTrue(b'johnsmith' not in serr)
|
|
|
|
self.assertTrue(b'-p' in serr)
|
2022-01-09 13:57:06 +00:00
|
|
|
self.assertTrue(b'my_secret_password' not in serr)
|
2016-08-02 15:03:46 +00:00
|
|
|
|
2016-11-17 11:42:56 +00:00
|
|
|
|
2016-08-02 15:03:46 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|