-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
-
pip list
of the virtual environment you are using
Python 3.6.5rc1
pytest 3.9.1 -
pytest and operating system versions
ArchLinux, 4.12.13-1-ARCH
Docker container -
Include a detailed description of the bug or suggestion
-
Minimal example if possible
pathlib.PosixPath.joinpath
which is used in _pytest.tmpdir.TempPathFactory.mktemp:44
works differently from previously used py.path.local.mkdir
in such way that given code:
@pytest.fixture
def tmp_work_dir(tmpdir_factory):
return tmpdir_factory.mktemp('/hello', numbered=False)
It tries to create temporary directory "/hello" instead "/tmp/pytest-of-user/pytest-0/hello" and fails when pathlib.PosixPath.mkdir()
is run with different errors depending where I run it.
In Docker container as "root" FileNotFoundError
:
================================================ ERRORS =================================================
________________________________________ ERROR at setup of test _________________________________________
tmpdir_factory = TempdirFactory(_tmppath_factory=TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0x7fa093ec9d30>, _basetemp=PosixPath('/tmp/pytest-of-root/pytest-95')))
@pytest.fixture
def tmp_work_dir(tmpdir_factory):
> return tmpdir_factory.mktemp('/hello', numbered=False)
src/testcases/conftest.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.6/pathlib.py:1246: in mkdir
self._accessor.mkdir(self, mode)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pathobj = PosixPath('/hello')
args = (511,)
@functools.wraps(strfunc)
def wrapped(pathobj, *args):
> return strfunc(str(pathobj), *args)
E FileNotFoundError: [Errno 2] No such file or directory: '/hello'
/usr/lib/python3.6/pathlib.py:387: FileNotFoundError
In my OS w/o root privileges OSError
:
================================================ ERRORS =================================================
________________________________________ ERROR at setup of test _________________________________________
tmpdir_factory = TempdirFactory(_tmppath_factory=TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0x7f384edf6a58>, _basetemp=PosixPath('/tmp/pytest-of-user/pytest-2')))
@pytest.fixture
def hi(tmpdir_factory):
import pdb; pdb.set_trace()
> return tmpdir_factory.mktemp('/hello')
E OSError: could not create numbered dir with prefix /hello in /tmp/pytest-of-user/pytest-2 after 10 tries
sandbox/blahpytest/conftest.py:6: OSError
======================================= 1 error in 18.22 seconds ========================================
When run with sudo
it works in my system however it doesn't help in Docker container.
Now in such case should it work in the new or old way?