Shadow the built in tmpdir fixture to use our Path object

* Uses the same generation method as the built in tmpdir, simply
  returns a different object type.
This commit is contained in:
Donald Stufft 2013-08-21 22:28:15 -04:00
parent d3b63817c1
commit bd127f8aba
1 changed files with 20 additions and 0 deletions

20
tests/conftest.py Normal file
View File

@ -0,0 +1,20 @@
import py
import pytest
from tests.lib.path import Path
@pytest.fixture
def tmpdir(request):
"""
Return a temporary directory path object which is unique to each test
function invocation, created as a sub directory of the base temporary
directory. The returned object is a ``tests.lib.path.Path`` object.
This is taken from pytest itself but modified to return our typical
path object instead of py.path.local.
"""
name = request.node.name
name = py.std.re.sub("[\W]", "_", name)
tmp = request.config._tmpdirhandler.mktemp(name, numbered=True)
return Path(tmp)