test_debug.py 937 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #
  2. # This file is part of pyasn1 software.
  3. #
  4. # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
  5. # License: https://pyasn1.readthedocs.io/en/latest/license.html
  6. #
  7. import sys
  8. import unittest
  9. from __tests__.base import BaseTestCase
  10. from pyasn1 import debug
  11. from pyasn1 import error
  12. class DebugCaseBase(BaseTestCase):
  13. def testKnownFlags(self):
  14. debug.setLogger(0)
  15. debug.setLogger(debug.Debug('all', 'encoder', 'decoder'))
  16. debug.setLogger(0)
  17. def testUnknownFlags(self):
  18. try:
  19. debug.setLogger(debug.Debug('all', 'unknown', loggerName='xxx'))
  20. except error.PyAsn1Error:
  21. debug.setLogger(0)
  22. return
  23. else:
  24. debug.setLogger(0)
  25. assert 0, 'unknown debug flag tolerated'
  26. suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
  27. if __name__ == '__main__':
  28. unittest.TextTestRunner(verbosity=2).run(suite)