[TIP] Coverage kills python with sys.settrace(None): how to work around?

Ned Batchelder ned at nedbatchelder.com
Mon Mar 9 06:32:20 PDT 2015

On 3/9/15 5:52 AM, Michael McNeil Forbes wrote:
> I am trying to run coverage via nosetests from setup.py, but once the coverage report is produced, coverage calls sys.settrace(None) which rapidly kills everything and I can no longer continue processing.  (I would like to run some additional tests after like pep8 syntax checks etc.)
I have not heard of this phenomenon before.  Can you provide more 
details?  Coverage ends its measurement by setting the trace function to 
None.  Is your code online? Do you have steps to reproduce the problem?

> How can I run coverage on my tests and then continue with other checks if everything is successful?
> Thanks,
> Michael.
> P.S.
> I am subclassing Command in my setup.py file defining a run command like:
>    def run(self):
>        self.run_command('nosetests')
>        self.run_command('flake8')
>        self.run_command('check')
> Even if all the nosetests pass, coverage kills everything when the tracer is stopped.  As such, I can't even catch an exception.
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

More information about the testing-in-python mailing list