Skip to content

Commit

Permalink
[tests] Give option of code coverage for explicitly mentioned packages
Browse files Browse the repository at this point in the history
- Earlier, code coverage reporting for was all packages only.
- Now, we have the option to only report coverage for specific packages by adding them as command-line input.

NOTE: Tests run for all packages, only coverage is reported for specific mentioned packages if this option is used.
  • Loading branch information
Harshg999 committed Feb 8, 2022
1 parent 9c88b46 commit 47f0433
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion desktop/core/src/desktop/lib/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,19 @@ def run_tests(self, test_labels, *args):
nose_argv.extend(args)

if hasattr(settings, 'NOSE_ARGS'):
nose_argv.extend(settings.NOSE_ARGS)
extended_nose_args = settings.NOSE_ARGS

# Remove coverage packages option from settings.NOSE_ARGS if explicitly mentioned as test command-line argument.
# This will help as an option to report coverage for specific packages only if required.
for nose_arg in nose_argv:
if nose_arg.startswith('--cover-package'):
extended_nose_args = []

for arg in settings.NOSE_ARGS:
if not arg.startswith('--cover-package'):
extended_nose_args.append(arg)

nose_argv.extend(extended_nose_args)

# Skip over 'manage.py test' and any arguments handled by django.
django_opts = ['--noinput', '--liveserver', '-p', '--pattern']
Expand Down

0 comments on commit 47f0433

Please sign in to comment.