pytest-cov: Failed to setup subprocess coverage if os.getcwd() fails
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-pytest-cov (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Upstream bug: https:/
Following sample test case causes pytest-cov to fail:
```
import os
import subprocess
import sys
import tempfile
import textwrap
import unittest
class Test(unittest.
maxDiff = None
def test_deleted_
"""Relative Python script from deleted working directory."""
orig_cwd = os.getcwd()
try:
with tempfile.
env = os.environ.copy()
)
finally:
"""
),
)
```
Run this script with `python3 -m pytest --cov=. test.py` and stderr will contain following stack trace:
```
Error processing line 1 of /usr/lib/
Traceback (most recent call last):
File "/usr/lib/
exec(line)
File "<string>", line 1, in <module>
File "/usr/lib/
import cov_core # noqa: register multiprocessing handler
File "/usr/lib/
import coverage
File "/usr/lib/
from coverage.control import Coverage, process_startup
File "/usr/lib/
from coverage.annotate import AnnotateReporter
File "/usr/lib/
from coverage.files import flat_rootname
File "/usr/lib/
set_
File "/usr/lib/
RELATIVE_DIR = os.path.
File "/usr/lib/
path = os.path.
File "/usr/lib/
return abspath(path)
File "/usr/lib/
cwd = os.getcwd()
FileNotFoundE
Remainder of file ignored
pytest-cov: Failed to setup subprocess coverage.
```
description: | updated |