Skip to content

Deleted working directory in pytest-cov 2.6.0+ #306

Closed
@effigies

Description

@effigies

For pytest-cov>=2.6, the following error results at the end of execution:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/_pytest/main.py", line 213, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/_pytest/main.py", line 257, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/pluggy/manager.py", line 87, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/pluggy/manager.py", line 81, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/pluggy/callers.py", line 203, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/pytest_cov/plugin.py", line 229, in pytest_runtestloop
INTERNALERROR>     self.cov_controller.finish()
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/pytest_cov/engine.py", line 171, in finish
INTERNALERROR>     self.cov.stop()
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/coverage/control.py", line 675, in load
INTERNALERROR>     self._init()
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/coverage/control.py", line 223, in _init
INTERNALERROR>     set_relative_directory()
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/coverage/files.py", line 28, in set_relative_directory
INTERNALERROR>     RELATIVE_DIR = os.path.normcase(abs_file(os.curdir) + os.sep)
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/site-packages/coverage/files.py", line 163, in abs_file
INTERNALERROR>     path = os.path.realpath(path)
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/posixpath.py", line 389, in realpath
INTERNALERROR>     return abspath(path)
INTERNALERROR>   File "/usr/local/miniconda/lib/python3.7/posixpath.py", line 376, in abspath
INTERNALERROR>     cwd = os.getcwd()
INTERNALERROR> FileNotFoundError: [Errno 2] No such file or directory

This appears to indicate that somewhere we change directories, then that directory gets deleted, and then os.getcwd() gets called via coverage.coverage(...).stop() before any chdir to an existing directory.

Downgrading to 2.5.1 resolves the problem. For reference, our call looks like:

pytest --junit-xml=/tmp/pytest.xml \
         --cov niworkflows --cov-report xml:/tmp/unittests.xml \
         --ignore=/src/niworkflows/niworkflows/tests/ \
         --ignore=/src/niworkflows/niworkflows/interfaces/ants.py \
         /src/niworkflows/niworkflows

Related: nedbat/coveragepy#750

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions