sparky
sparky

Reputation: 11

Coverage report of nosetests in case of child process

I am using nosetests for unit testing of some python script. The script in question creates a child process. I am executing the script using the command : nosetests -s -v 'python script.py' --with-coverage

I have installed nose-cov. Its version is 1.6.

The coverage report that I am getting doesn't contain the coverage of the code executed by the child.

IS THERE ANY WAY OF GETTING THE COVERAGE OF THE CHILD PROCESS??

Thanks

Upvotes: 0

Views: 649

Answers (1)

Oleksiy
Oleksiy

Reputation: 6567

Nose is using outstanding coverage package under covers do the job. Assuming that you launch of your child process using subprocess, within your test you can temporarily mock or monkey patch the launch your child as:

subprocess.call(['coverage', 'run', 'my_child_program.py', '-p'])

With -p option to combine reports. You may need other options to make sure that your nose options point to the same .coverage report file as your subprocess call.

Upvotes: 2

Related Questions