coverage of (sub)processes without setting COVERAGE_PROCESS_START env

Issue #344 invalid
Tim Tisdall created an issue

I may just be doing something wrong here so I apologize if this isn't a real issue, but something is definitely not working correctly.

To start with, I posted this question which Ned answered: http://stackoverflow.com/questions/27363230/python-unittest-with-coverage-report-on-subprocesses/

I changed my sitecustomize.py to be:

import coverage
coverage.process_startup()

... because I didn't want to be running coverage during normal usage. My understanding from the docs is that it shouldn't do anything unless it finds the COVERAGE_PROCESS_START environment variable. However when I try to kill my program that's running as user www-data I get the following error:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/sites/metrics_dev/env/lib/python3.4/site-packages/coverage/control.py", line 417, in _atexit
    self.save()
  File "/sites/metrics_dev/env/lib/python3.4/site-packages/coverage/control.py", line 493, in save
    self.data.write(suffix=data_suffix)
  File "/sites/metrics_dev/env/lib/python3.4/site-packages/coverage/data.py", line 91, in write
    self.write_file(filename)
  File "/sites/metrics_dev/env/lib/python3.4/site-packages/coverage/data.py", line 131, in write_file
    fdata = open(filename, 'wb')
PermissionError: [Errno 13] Permission denied: '/.coverage.dev.12466.403470'

This indicates that it's trying to write coverage details to a file even though I haven't set the environment variable. Originally I thought this was due to a cached .pyc file in pycache but after deleting that I'm still getting that error message.

Comments (1)

  1. Tim Tisdall reporter

    I found where it was setting the environment variable! Sorry!

    I'm still having an issue with getting to track code usage in the sub-process though... it outputs with the print statements but coverage doesn't see that it's running those commands.

  2. Log in to comment