add a rootdir param to py.path.local.mkdtemp
--HG-- branch : trunk
This commit is contained in:
parent
2e82ca5fde
commit
f8404be1b2
|
@ -628,12 +628,14 @@ class LocalPath(FSBase):
|
||||||
return py.path.local(py.std.tempfile.gettempdir())
|
return py.path.local(py.std.tempfile.gettempdir())
|
||||||
get_temproot = classmethod(get_temproot)
|
get_temproot = classmethod(get_temproot)
|
||||||
|
|
||||||
def mkdtemp(cls):
|
def mkdtemp(cls, rootdir=None):
|
||||||
""" return a Path object pointing to a fresh new temporary directory
|
""" return a Path object pointing to a fresh new temporary directory
|
||||||
(which we created ourself).
|
(which we created ourself).
|
||||||
"""
|
"""
|
||||||
import tempfile
|
import tempfile
|
||||||
return cls(py.error.checked_call(tempfile.mkdtemp))
|
if rootdir is None:
|
||||||
|
rootdir = cls.get_temproot()
|
||||||
|
return cls(py.error.checked_call(tempfile.mkdtemp, dir=str(rootdir)))
|
||||||
mkdtemp = classmethod(mkdtemp)
|
mkdtemp = classmethod(mkdtemp)
|
||||||
|
|
||||||
def make_numbered_dir(cls, prefix='session-', rootdir=None, keep=3,
|
def make_numbered_dir(cls, prefix='session-', rootdir=None, keep=3,
|
||||||
|
|
|
@ -389,6 +389,10 @@ def test_samefile(tmpdir):
|
||||||
p = tmpdir.ensure("hello")
|
p = tmpdir.ensure("hello")
|
||||||
assert p.samefile(p)
|
assert p.samefile(p)
|
||||||
|
|
||||||
|
def test_mkdtemp_rootdir(tmpdir):
|
||||||
|
dtmp = local.mkdtemp(rootdir=tmpdir)
|
||||||
|
assert tmpdir.listdir() == [dtmp]
|
||||||
|
|
||||||
class TestWINLocalPath:
|
class TestWINLocalPath:
|
||||||
pytestmark = win32only
|
pytestmark = win32only
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue