Consider adding environment variable when running

Issue #553 closed
Pedro Algarvio created an issue

When checking coverage using "coverage run" consider injecting a COVERAGE_<whatever> environment variable.

This would allow detecting that the code is being covered and proceed acroding to that information.

For example, to speed up tests I often just kill any subprocesses spawned instead of terminating them(yes we spawn a lot of processes and it does make a huge difference), however, this results in the coverage data not being written.

Should I provide a PR?

Maybe COVERAGE_COMMAND, which in this case would be set to run?

Comments (6)

  1. Ned Batchelder repo owner

    I think it would be better if you handle this on your own: however you are running coverage, you can define an environment variable of your own to affect your test running.

  2. Pedro Algarvio reporter

    On our CI environment, I am handling this myself, however, if I want to run coverage locally, I need to add the variables every time.

    For a single person team, doable, for huge teams(error prone), for third party contributors, even more error prone since some don't even read docs.

    This would just be a convenience, a big convenience on our part.

    If you, however, feel strongly against the procedure, feel free to close the issue.

  3. Pedro Algarvio reporter

    I'm using pytest, and even though pytest-cov exists, it misses whatever is imported on the main prior to starting, hence me running "coverage run" instead...

  4. Ned Batchelder repo owner

    Tell me more about your environment. You don't have a Makefile or a tox.ini that controls the launching of the test runner?

  5. Pedro Algarvio reporter

    No tox.ini, we target a specific python version and the test environment is built as part of the CI process, sobno need to bring in tox And no Makefile either, its a direct py.test call.

    Perhaps a more meaningful environment variable. The path to the used configuration file?! If found and not already present in the environment?

    I'm guessing I might be pushing too much but I can't even inspect sys.argv since coverage does the right thing and clears its tracks from it.

  6. Log in to comment