Deleted working directory in pytest-cov 2.6.0+
See original GitHub issueFor 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Developers - Deleted working directory in pytest-cov 2.6.0+ -
For pytest-cov>=2.6 , the following error results at the end of execution: INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File ...
Read more >pytest-cov - Read the Docs
This plugin produces coverage reports. Compared to just using coverage run this plugin does some extras: • Subprocess support: you can fork ...
Read more >Release 2.6.0 - Pytest-Cov
path (CWD will be in it, unlike when running pytest). ... The data file is erased at the beginning of testing to ensure...
Read more >How to debug py.test in PyCharm when coverage is enabled
5, pytest-cache==1.0, pytest-cov==2.2.0, pytest-pep8==1.0.6, pytest-xdist==1.13.1, python-coveralls==2.6.0. (thanks for ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s arguably not a bug for a test to change the working directory
Consider this which I consider well formed:
pytest-cov should be keeping absolute paths on construction and using those throughout
Took some time but: 6b1e878f3654d3758bd7f3fefcc90b0b828d158e