coverage.py

How to instruct coverage.py to omit top-level definitions and count only method's bodies?

半城伤御伤魂 提交于 2019-12-07 18:14:26
问题 I want to test the coverage of a single package within a large body of software (specifically an Odoo addon). I have no control over the overall setup of the test. Hacking Odoo to start the coverage collection before loading the modules is not worth it -- running all Odoo tests takes about 20 minutes on regular hardware; so I want to selectively test the coverage of some custom modules. I'm using setUpModule and tearDownModule like this: _coverage = Coverage( source=[ 'odoo.addons.xhg

Getting coverage with dev_appserver.py excludes my project files

落爺英雄遲暮 提交于 2019-12-07 00:21:39
问题 I run the following with Coverage 3.6, Appengine 1.8.0, Python 2.7.4 on 64 bit Ubuntu 13.04: coverage run dev_appserver.py project When I look at coverage results I can see details for all files except the ones in my project. They show up as zero lines executed if I add --source=project . Trying --timid made no difference. I can see others doing the exact same thing - example 1 2 - implying this used to work. I terminate coverage/dev_appserver by sending SIGINT, and do wait for it to exit. My

How do I generate coverage xml report for a single package?

…衆ロ難τιáo~ 提交于 2019-12-05 22:08:04
I'm using nose and coverage to generate coverage reports. I only have one package right now, ae , so I specify to only cover that: nosetests -w tests/unit --with-xunit --with-coverage --cover-package=ae And here are the results, which look good: Name Stmts Exec Cover Missing ---------------------------------------------- ae 1 1 100% ae.util 253 224 88% 39, 63-65, 284, 287, 362, 406 ---------------------------------------------- TOTAL 263 234 88% ---------------------------------------------------------------------- Ran 68 tests in 5.292s However when I run coverage xml , coverage pulls in more

How to instruct coverage.py to omit top-level definitions and count only method's bodies?

不问归期 提交于 2019-12-05 20:35:57
I want to test the coverage of a single package within a large body of software (specifically an Odoo addon). I have no control over the overall setup of the test. Hacking Odoo to start the coverage collection before loading the modules is not worth it -- running all Odoo tests takes about 20 minutes on regular hardware; so I want to selectively test the coverage of some custom modules. I'm using setUpModule and tearDownModule like this: _coverage = Coverage( source=[ 'odoo.addons.xhg_autrement_prices.models', ], config_file=_join('.coveragerc'), auto_data=True, data_file=_join('.coverage'), )

combine python coverage files?

廉价感情. 提交于 2019-12-05 11:36:15
问题 I'm wondering if it's possible to combine coverage.xml files into 1 file to see global report in HTML output. I've got my unit/functional tests running as 1 command and integration tests as the second command. That means my coverage for unit/functional tests are overridden by unit tests . That would be great if I had some solution for that problem, mainly by combining those files into 1 file. 回答1: You can't combine .xml files, but you can combine the raw data files. Your workflow would look

Getting coverage with dev_appserver.py excludes my project files

回眸只為那壹抹淺笑 提交于 2019-12-05 05:26:28
I run the following with Coverage 3.6 , Appengine 1.8.0, Python 2.7.4 on 64 bit Ubuntu 13.04: coverage run dev_appserver.py project When I look at coverage results I can see details for all files except the ones in my project. They show up as zero lines executed if I add --source=project . Trying --timid made no difference. I can see others doing the exact same thing - example 1 2 - implying this used to work. I terminate coverage/dev_appserver by sending SIGINT, and do wait for it to exit. My suspicion is that the chicanery dev_appserver does to replicate the production environment (eg

Python Code Coverage and Multiprocessing

非 Y 不嫁゛ 提交于 2019-12-04 22:51:31
I use coveralls in combination with coverage.py to track python code coverage of my testing scripts. I use the following commands: coverage run --parallel-mode --source=mysource --omit=*/stuff/idont/need.py ./mysource/tests/run_all_tests.py coverage combine coveralls --verbose This works quite nicely with the exception of multiprocessing . Code executed by worker pools or child processes is not tracked. Is there a possibility to also track multiprocessing code? Any particular option I am missing? Maybe adding wrappers to the multiprocessing library to start coverage every time a new process is

Disabling nose coverage report to STDOUT when HTML report is enabled?

折月煮酒 提交于 2019-12-04 02:33:36
I'm using nose (via django-nose ) with the coverage plugin to check test coverage of my Django project. I've configured nose to generate an HTML coverage report on every test run: NOSE_ARGS = [ '--with-coverage', '--cover-package=foot', '--cover-html', '--cover-html-dir=cover', ] Now, I want to disable the plain-text coverage report that gets shown after every test run; the HTML is much more functional, and the long badly-formatted table makes it hard to see actual test output. Neither nosetests nor coverage seems to have such an option, or perhaps I just can't find one? scjody (Taken from

Running tests from coverage.py vs running coverage from test runner

我只是一个虾纸丫 提交于 2019-12-03 17:19:44
During the Coverage.py with Ned Batchelder python&testing podcast, Brian and Ned briefly discussed that, if you need to run tests with coverage, it is preferred to run tests from coverage.py executing the coverage run as opposed to invoking a test runner with coverage. Why is that and what is the difference? To put some context into this: currently I'm using nose test runner and execute the tests with the help of nosetests command-line tool with --with-coverage option : $ nosetests --with-coverage --cover-html Should I do it via the coverage run -m instead? $ coverage run -m nose $ coverage

Is it possible exclude test directories from coverage.py reports?

和自甴很熟 提交于 2019-12-03 11:27:26
问题 I'm kind of a rookie with python unit testing, and particularly coverage.py. Is it desirable to have coverage reports include the coverage of your actual test files? Here's a screenshot of my HTML report as an example. You can see that the report includes tests/test_credit_card . At first I was trying to omit the tests/ directory from the reports, like so: coverage html --omit=tests/ -d tests/coverage I tried several variations of that command but I could not for the life of me get the tests/