test_runner.py 932 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python3
  2. #
  3. # Copyright (C) 2016 Intel Corporation
  4. #
  5. # SPDX-License-Identifier: MIT
  6. #
  7. import unittest
  8. import logging
  9. import tempfile
  10. from common import setup_sys_path, TestBase
  11. setup_sys_path()
  12. from oeqa.core.runner import OEStreamLogger
  13. class TestRunner(TestBase):
  14. def test_stream_logger(self):
  15. fp = tempfile.TemporaryFile(mode='w+')
  16. logging.basicConfig(format='%(message)s', stream=fp)
  17. logger = logging.getLogger()
  18. logger.setLevel(logging.INFO)
  19. oeSL = OEStreamLogger(logger)
  20. lines = ['init', 'bigline_' * 65535, 'morebigline_' * 65535 * 4, 'end']
  21. for line in lines:
  22. oeSL.write(line)
  23. fp.seek(0)
  24. fp_lines = fp.readlines()
  25. for i, fp_line in enumerate(fp_lines):
  26. fp_line = fp_line.strip()
  27. self.assertEqual(lines[i], fp_line)
  28. fp.close()
  29. if __name__ == '__main__':
  30. unittest.main()