Fail gracefully when reporting on file with a syntax error · Issue #115 · nedbat/coveragepy (original) (raw)

Originally reported by Ram Rachum (Bitbucket: coolrr, GitHub: coolrr)


I'm running coverage for a package which has a module with an //intentional// syntax error in it. This is a test package called test_garlicsim which tests that garlicsim handles syntax errors correctly.

I want to run coverage on test_garlicsim. I'm able to run the coverage analysis, but the report part fails with this error message:

Couldn't parse 'c:\documents and settings\user\my documents\python projects\garlicsim\garlicsim\test_garlicsim\test_misc
\test_simpack_grokker\test_problematic_simpacks\sample_problematic_simpacks\simpack_with_syntax_error_in_settings\settin
gs.py' as Python source: 'invalid syntax' at line 1

I want coverage to fail gracefully in this case; for example, in this case I'd be happy if it just avoided that specific troublesome module while still reporting on all the other hundreds of modules in the test_garlicsim package.