Python Library Unittest
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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import os
  5. from unittest.output import termcolors, coverage_output
  6. from unittest.output import STATUS_COLORS, STATUS_UNKNOWN
  7. from unittest.jsonlog import lib_coverage, status_doc, status_git, status_lib_unittest, status_spec, versions_module
  8. STATUS_LENGTH = 13
  9. def status_output(status_or_text, default_color=STATUS_COLORS[STATUS_UNKNOWN]):
  10. if status_or_text in STATUS_COLORS:
  11. default_color = STATUS_COLORS[status_or_text]
  12. return default_color + (STATUS_LENGTH - len(status_or_text[:STATUS_LENGTH])) * ' ' + status_or_text[:STATUS_LENGTH] + termcolors.ENDC
  13. def module_status_head():
  14. rv = termcolors.BOLD + termcolors.UNDERLINE + 'Status of the unittests for pylibs:\n' + termcolors.ENDC
  15. LINE_FORMAT = '%25s%' + str(STATUS_LENGTH) + 's%' + str(STATUS_LENGTH) + 's%' + str(STATUS_LENGTH) + 's%' + str(STATUS_LENGTH) + 's%' + str(STATUS_LENGTH) + 's%' + str(STATUS_LENGTH) + 's\n'
  16. rv += termcolors.BOLD + termcolors.HEADER + LINE_FORMAT % (
  17. 'Library',
  18. 'UT-Status',
  19. 'DOC-Status',
  20. 'Versions',
  21. 'UT-Coverage',
  22. 'SPEC-Status',
  23. 'GIT-Status',
  24. )
  25. rv += (25 + 6 * STATUS_LENGTH) * '-' + '\n' + termcolors.ENDC
  26. return rv
  27. def module_status_line(ut_folder):
  28. rv = '%25s%s%s%s%s%s%s\n' % (
  29. os.path.basename(ut_folder) + ':',
  30. status_output(status_lib_unittest(ut_folder)),
  31. status_output(status_doc(ut_folder)),
  32. status_output(versions_module(ut_folder), termcolors.BOLD),
  33. coverage_output(*lib_coverage(ut_folder), length=STATUS_LENGTH),
  34. status_output(status_spec(ut_folder)),
  35. status_output(status_git(ut_folder)),
  36. )
  37. return rv