FileNotFoundError for lock file with tmpdir for old pytest-of-user root
See original GitHub issueWith an existing /tmp/pytest-of-user
directory there will be an error now:
___ ERROR at setup of TestGeneralUsage.test_config_error ___
self = <CallInfo when='setup' exception: [Errno 2] No such file or directory: '/tmp/pytest-of-daniel/pytest-current/.lock'>, func = <function call_runtest_hook.<locals>.<lambda> at 0x7f88d52cc0d0>, when = 'setup'
treat_keyboard_interrupt_as_exception = False
def __init__(self, func, when, treat_keyboard_interrupt_as_exception=False):
#: context of invocation: one of "setup", "call",
#: "teardown", "memocollect"
self.when = when
self.start = time()
try:
> self.result = func()
src/_pytest/runner.py:201:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/_pytest/runner.py:183: in <lambda>
lambda: ihook(item=item, **kwds),
.venv/lib/python3.6/site-packages/pluggy/hooks.py:258: in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
.venv/lib/python3.6/site-packages/pluggy/manager.py:67: in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
.venv/lib/python3.6/site-packages/pluggy/manager.py:61: in <lambda>
firstresult=hook.spec_opts.get('firstresult'),
src/_pytest/runner.py:104: in pytest_runtest_setup
item.session._setupstate.prepare(item)
src/_pytest/runner.py:370: in prepare
col.setup()
src/_pytest/python.py:1439: in setup
fixtures.fillfixtures(self)
src/_pytest/fixtures.py:294: in fillfixtures
request._fillfixtures()
src/_pytest/fixtures.py:467: in _fillfixtures
item.funcargs[argname] = self.getfixturevalue(argname)
src/_pytest/fixtures.py:514: in getfixturevalue
return self._get_active_fixturedef(argname).cached_result[0]
src/_pytest/fixtures.py:537: in _get_active_fixturedef
self._compute_fixture_value(fixturedef)
src/_pytest/fixtures.py:623: in _compute_fixture_value
fixturedef.execute(request=subrequest)
src/_pytest/fixtures.py:919: in execute
return hook.pytest_fixture_setup(fixturedef=self, request=request)
.venv/lib/python3.6/site-packages/pluggy/hooks.py:258: in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
.venv/lib/python3.6/site-packages/pluggy/manager.py:67: in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
.venv/lib/python3.6/site-packages/pluggy/manager.py:61: in <lambda>
firstresult=hook.spec_opts.get('firstresult'),
src/_pytest/fixtures.py:961: in pytest_fixture_setup
result = call_fixture_func(fixturefunc, request, kwargs)
src/_pytest/fixtures.py:820: in call_fixture_func
res = fixturefunc(**kwargs)
src/_pytest/pytester.py:371: in testdir
return Testdir(request, tmpdir_factory)
src/_pytest/pytester.py:498: in __init__
self.tmpdir = tmpdir_factory.mktemp(name, numbered=True)
src/_pytest/tmpdir.py:103: in mktemp
return py.path.local(self._tmppath_factory.mktemp(basename, numbered).resolve())
src/_pytest/tmpdir.py:47: in mktemp
p = make_numbered_dir(root=self.getbasetemp(), prefix=basename)
src/_pytest/tmpdir.py:66: in getbasetemp
prefix="pytest-", root=rootdir, keep=3, lock_timeout=LOCK_TIMEOUT
src/_pytest/pathlib.py:233: in make_numbered_dir_with_cleanup
consider_lock_dead_if_created_before=consider_lock_dead_if_created_before,
src/_pytest/pathlib.py:212: in cleanup_numbered_dir
try_cleanup(path, consider_lock_dead_if_created_before)
src/_pytest/pathlib.py:194: in try_cleanup
delete_a_numbered_dir(path)
src/_pytest/pathlib.py:166: in delete_a_numbered_dir
create_cleanup_lock(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
p = PosixPath('/tmp/pytest-of-user/pytest-current')
def create_cleanup_lock(p):
"""crates a lock to prevent premature folder cleanup"""
lock_path = get_lock_path(p)
try:
> fd = os.open(str(lock_path), os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o644)
E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pytest-of-user/pytest-current/.lock'
src/_pytest/pathlib.py:127: FileNotFoundError
============================================================================================== short test summary info ==============================================================================================
ERROR testing/acceptance_test.py::TestGeneralUsage::()::test_config_error
============================================================================================== 1 error in 0.32 seconds ==============================================================================================
―
This is due to recent changes, but have not bisected it.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
How to use temporary directories and files in tests - Pytest
Temporary directories are by default created as sub-directories of the system temporary directory. The base name will be pytest-NUM where NUM will be ......
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 Free
Top 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
rm -rf /tmp/pytest-of-user
fixes it as a workaround.bugfix pending - thanks for catching and reporting so swiftly ^^