Skip to content

Commit

Permalink
Merge pull request #76 from niphlod/feature/coverage
Browse files Browse the repository at this point in the history
coverage integration
  • Loading branch information
mdipierro committed Apr 16, 2013
2 parents c1f0bc3 + ad4870e commit b0e3e38
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ matrix:
- python: 'pypy'
env: DB=mysql://root:@localhost/test_w2p

script: export COVERAGE_PROCESS_START=gluon/tests/.coveragerc; ./web2py.py --run_system_tests --with_coverage
script: export COVERAGE_PROCESS_START=gluon/tests/coverage.ini; ./web2py.py --run_system_tests --with_coverage
after_success:
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then coverage combine; fi
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then coveralls --config_file=gluon/tests/.coveragerc; fi
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then coveralls --config_file=gluon/tests/coverage.ini; fi

notifications:
email: true
2 changes: 1 addition & 1 deletion gluon/contenttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@
'.pln': 'application/x-planperfect',
'.pls': 'audio/x-scpls',
'.pm': 'application/x-perl',
'.png': 'image/x-apple-ios-png',
'.png': 'image/png',
'.pnm': 'image/x-portable-anymap',
'.pntg': 'image/x-macpaint',
'.po': 'text/x-gettext-translation',
Expand Down
30 changes: 30 additions & 0 deletions gluon/tests/coverage.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[run]
branch = True
parallel = True
source = gluon
## remove comment if you want applications coverage too
#source = gluon, applications

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain about missing debug-only code:
def __repr__
if self\.debug

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError

# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:

ignore_errors = True
omit = gluon/contrib/*

[html]
directory = coverage_html_report
9 changes: 7 additions & 2 deletions gluon/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def run_system_tests(options):
if options.with_coverage:
try:
import coverage
coverage_config = os.path.join('gluon', 'tests', '.coveragerc')
coverage_config = os.environ.get("COVERAGE_PROCESS_START",
os.path.join('gluon', 'tests', 'coverage.ini')
)
call_args = ['coverage', 'run', '--rcfile=%s' % coverage_config,
'-m', 'unittest', '-v', 'gluon.tests']
except:
Expand Down Expand Up @@ -916,7 +918,10 @@ def console():
help=msg)

msg = ('adds coverage reporting (needs --run_system_tests), '
'python 2.7 and the coverage module installed')
'python 2.7 and the coverage module installed. '
'You can alter the default path setting the environmental '
'var "COVERAGE_PROCESS_START". '
'By default it takes gluon/tests/coverage.ini')
parser.add_option('--with_coverage',
action='store_true',
dest='with_coverage',
Expand Down

0 comments on commit b0e3e38

Please sign in to comment.