Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
  2. # MIT License. See LICENSE
  3. """
  4. frappe.coverage
  5. ~~~~~~~~~~~~~~~~
  6. Coverage settings for frappe
  7. """
  8. STANDARD_INCLUSIONS = ["*.py"]
  9. STANDARD_EXCLUSIONS = [
  10. '*.js',
  11. '*.xml',
  12. '*.pyc',
  13. '*.css',
  14. '*.less',
  15. '*.scss',
  16. '*.vue',
  17. '*.html',
  18. '*/test_*',
  19. '*/node_modules/*',
  20. '*/doctype/*/*_dashboard.py',
  21. '*/patches/*',
  22. ]
  23. FRAPPE_EXCLUSIONS = [
  24. "*/tests/*",
  25. "*/commands/*",
  26. "*/frappe/change_log/*",
  27. "*/frappe/exceptions*",
  28. "*/frappe/coverage.py",
  29. "*frappe/setup.py",
  30. "*/doctype/*/*_dashboard.py",
  31. "*/patches/*",
  32. ]
  33. class CodeCoverage():
  34. def __init__(self, with_coverage, app):
  35. self.with_coverage = with_coverage
  36. self.app = app or 'frappe'
  37. def __enter__(self):
  38. if self.with_coverage:
  39. import os
  40. from coverage import Coverage
  41. from frappe.utils import get_bench_path
  42. # Generate coverage report only for app that is being tested
  43. source_path = os.path.join(get_bench_path(), 'apps', self.app)
  44. omit = STANDARD_EXCLUSIONS[:]
  45. if self.app == 'frappe':
  46. omit.extend(FRAPPE_EXCLUSIONS)
  47. self.coverage = Coverage(source=[source_path], omit=omit, include=STANDARD_INCLUSIONS)
  48. self.coverage.start()
  49. def __exit__(self, exc_type, exc_value, traceback):
  50. if self.with_coverage:
  51. self.coverage.stop()
  52. self.coverage.save()
  53. self.coverage.xml_report()