test_verbose_output.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/env python3
  2. # Allow direct execution
  3. import os
  4. import sys
  5. import unittest
  6. sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  7. import subprocess
  8. rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  9. class TestVerboseOutput(unittest.TestCase):
  10. def test_private_info_arg(self):
  11. outp = subprocess.Popen(
  12. [
  13. sys.executable, 'yt_dlp/__main__.py',
  14. '-v', '--ignore-config',
  15. '--username', 'johnsmith@gmail.com',
  16. '--password', 'my_secret_password',
  17. ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  18. sout, serr = outp.communicate()
  19. self.assertTrue(b'--username' in serr)
  20. self.assertTrue(b'johnsmith' not in serr)
  21. self.assertTrue(b'--password' in serr)
  22. self.assertTrue(b'my_secret_password' not in serr)
  23. def test_private_info_shortarg(self):
  24. outp = subprocess.Popen(
  25. [
  26. sys.executable, 'yt_dlp/__main__.py',
  27. '-v', '--ignore-config',
  28. '-u', 'johnsmith@gmail.com',
  29. '-p', 'my_secret_password',
  30. ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  31. sout, serr = outp.communicate()
  32. self.assertTrue(b'-u' in serr)
  33. self.assertTrue(b'johnsmith' not in serr)
  34. self.assertTrue(b'-p' in serr)
  35. self.assertTrue(b'my_secret_password' not in serr)
  36. def test_private_info_eq(self):
  37. outp = subprocess.Popen(
  38. [
  39. sys.executable, 'yt_dlp/__main__.py',
  40. '-v', '--ignore-config',
  41. '--username=johnsmith@gmail.com',
  42. '--password=my_secret_password',
  43. ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  44. sout, serr = outp.communicate()
  45. self.assertTrue(b'--username' in serr)
  46. self.assertTrue(b'johnsmith' not in serr)
  47. self.assertTrue(b'--password' in serr)
  48. self.assertTrue(b'my_secret_password' not in serr)
  49. def test_private_info_shortarg_eq(self):
  50. outp = subprocess.Popen(
  51. [
  52. sys.executable, 'yt_dlp/__main__.py',
  53. '-v', '--ignore-config',
  54. '-u=johnsmith@gmail.com',
  55. '-p=my_secret_password',
  56. ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  57. sout, serr = outp.communicate()
  58. self.assertTrue(b'-u' in serr)
  59. self.assertTrue(b'johnsmith' not in serr)
  60. self.assertTrue(b'-p' in serr)
  61. self.assertTrue(b'my_secret_password' not in serr)
  62. if __name__ == '__main__':
  63. unittest.main()