Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
ac38d5b4
Commit
ac38d5b4
authored
6 years ago
by
Alex Dusenbery
Committed by
Alex Dusenbery
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Create a local .coveragerc file, update testing docs.
parent
6fa5893a
No related branches found
Branches containing commit
Tags
release-2021-04-15-15.25
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.coveragerc-local
+51
-0
51 additions, 0 deletions
.coveragerc-local
docs/testing.rst
+31
-3
31 additions, 3 deletions
docs/testing.rst
with
82 additions
and
3 deletions
.coveragerc-local
0 → 100644
+
51
−
0
View file @
ac38d5b4
# .coveragerc for edx-platform
[run]
data_file = reports/.coverage
source =
cms
common/djangoapps
common/lib/calc
common/lib/capa
common/lib/xmodule
lms
openedx
pavelib
scripts
omit =
cms/envs/*
cms/manage.py
cms/djangoapps/contentstore/views/dev.py
cms/djangoapps/*/migrations/*
cms/djangoapps/*/features/*
cms/lib/*/migrations/*
lms/debug/*
lms/envs/*
lms/djangoapps/*/migrations/*
lms/djangoapps/*/features/*
common/djangoapps/terrain/*
common/djangoapps/*/migrations/*
openedx/core/djangoapps/*/migrations/*
openedx/core/djangoapps/debug/*
openedx/features/*/migrations/*
concurrency=multiprocessing
parallel = true
[report]
ignore_errors = True
exclude_lines =
pragma: no cover
raise NotImplementedError
[html]
title = edx-platform Python Test Coverage Report
directory = reports/cover
[xml]
output = reports/coverage.xml
[paths]
source =
/edx/app/edxapp/edx-platform
This diff is collapsed.
Click to expand it.
docs/testing.rst
+
31
−
3
View file @
ac38d5b4
...
...
@@ -208,6 +208,9 @@ To run a single django test class use this command::
paver test_system -t lms/djangoapps/courseware/tests/tests.py::ActivateLoginTest
Running a Single Test
---------------------
When developing tests, it is often helpful to be able to really just run
one single test without the overhead of PIP installs, UX builds, etc. In
this case, it is helpful to look at the output of paver, and run just
...
...
@@ -291,15 +294,40 @@ This is an example of how to run a single test and get stdout shown immediately,
pytest cms/djangoapps/contentstore/tests/test_import.py -s
How to output coverage locally
------------------------------
These are examples of how to run a single test and get coverage::
pytest cms/djangoapps/contentstore/tests/test_import.py --cov # cms example
pytest lms/djangoapps/courseware/tests/test_module_render.py --cov # lms example
pytest cms/djangoapps/contentstore/tests/test_import.py --cov --cov-conifg=.coveragerc-local # cms example
pytest lms/djangoapps/courseware/tests/test_module_render.py --cov --cov-conifg=.coveragerc-local # lms example
That ``--cov-conifg=.coveragerc-local`` option is important - without it, the coverage
tool will look for paths that exist on our jenkins test servers, but not on your local devstack.
How to spit out coverage for a single file with a list of each line that is missing coverage::
Use this command to generate a coverage report::
pytest lms/djangoapps/grades/tests/test_subsection_grade.py \
--cov=lms.djangoapps.grades.subsection_grade \
--cov-config=.coveragerc-local \
--cov-report=term-missing
---------- coverage: platform linux2, python 2.7.12-final-0 ----------
Name Stmts Miss Cover Missing
-------------------------------------------------------------------------
lms/djangoapps/grades/subsection_grade.py 125 38 70% 47-51, 57, 80-81, 85, 89, 99, 109, 113, [...]
Use this command to generate a coverage report (after previously running ``pytest``)::
coverage report
The above command looks for a test coverage data file in ``reports/.coverage`` - this file will
contain coverage data from your last run of ``pytest``. Coverage data is recorded for whichever
paths you specified in your ``--cov`` option, e.g.::
--cov=. # will track coverage for the entire project
--cov=path.to.your.module # will track coverage only for "module"
Use this command to generate an HTML report::
coverage html
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment