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.

70 lines
2.5 KiB

  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. sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  9. rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  10. class TestVerboseOutput(unittest.TestCase):
  11. def test_private_info_arg(self):
  12. outp = subprocess.Popen(
  13. [
  14. sys.executable, 'youtube_dl/__main__.py', '-v',
  15. '--username', 'johnsmith@gmail.com',
  16. '--password', 'secret',
  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'secret' not in serr)
  23. def test_private_info_shortarg(self):
  24. outp = subprocess.Popen(
  25. [
  26. sys.executable, 'youtube_dl/__main__.py', '-v',
  27. '-u', 'johnsmith@gmail.com',
  28. '-p', 'secret',
  29. ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  30. sout, serr = outp.communicate()
  31. self.assertTrue(b'-u' in serr)
  32. self.assertTrue(b'johnsmith' not in serr)
  33. self.assertTrue(b'-p' in serr)
  34. self.assertTrue(b'secret' not in serr)
  35. def test_private_info_eq(self):
  36. outp = subprocess.Popen(
  37. [
  38. sys.executable, 'youtube_dl/__main__.py', '-v',
  39. '--username=johnsmith@gmail.com',
  40. '--password=secret',
  41. ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  42. sout, serr = outp.communicate()
  43. self.assertTrue(b'--username' in serr)
  44. self.assertTrue(b'johnsmith' not in serr)
  45. self.assertTrue(b'--password' in serr)
  46. self.assertTrue(b'secret' not in serr)
  47. def test_private_info_shortarg_eq(self):
  48. outp = subprocess.Popen(
  49. [
  50. sys.executable, 'youtube_dl/__main__.py', '-v',
  51. '-u=johnsmith@gmail.com',
  52. '-p=secret',
  53. ], cwd=rootDir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  54. sout, serr = outp.communicate()
  55. self.assertTrue(b'-u' in serr)
  56. self.assertTrue(b'johnsmith' not in serr)
  57. self.assertTrue(b'-p' in serr)
  58. self.assertTrue(b'secret' not in serr)
  59. if __name__ == '__main__':
  60. unittest.main()