Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
test-backend: Display test function in HTML coverage reports.
Adam Sah492272d597eb
diff --git a/docs/testing/testing-with-django.md b/docs/testing/testing-with-django.mdindex 50d98a28fad..d62efa20dc8 100644--- a/docs/testing/testing-with-django.md+++ b/docs/testing/testing-with-django.md@@ -481,6 +481,10 @@ Here are some things to consider when writing new tests:view right from your browser (the tool prints the URL where the reportis exposed in your development environment).+ The HTML report also displays which tests executed each line, which+ can be handy for finding existing tests for a code path you're+ working on.+- **Console output** A properly written test should print nothing tothe console; use `with self.assertLogs` to capture and verify anylogging output. Note that we reconfigure various loggers indiff --git a/tools/coveragerc b/tools/coveragercindex 7c3ee2d027f..d651f31ba4d 100644--- a/tools/coveragerc+++ b/tools/coveragerc@@ -24,6 +24,13 @@ exclude_lines =[run]data_file=var/.coverage++# dynamic_context=test_function, combined with using+# html_report(..., show_contexts=True), means the HTML report can detail+# which test(s) executed each line with coverage. This has modest+# overhead but is very useful for finding existing tests for a code path.+dynamic_context=test_function+omit =*/zulip-venv-cache/**/migrations/*diff --git a/tools/test-backend b/tools/test-backendindex 28b71b6be4c..6f9eeeb8c38 100755--- a/tools/test-backend+++ b/tools/test-backend@@ -442,7 +442,7 @@ def main() -> None:print("Printing coverage data")cov.report(show_missing=False)cov.xml_report(outfile="var/coverage.xml")- cov.html_report(directory="var/coverage")+ cov.html_report(directory="var/coverage", show_contexts=True)print("HTML report saved; visit at http://127.0.0.1:9991/coverage/index.html")if full_suite and not failures and options.coverage:# Assert that various files have full coverage