@pytest.fixture
def tmpdir(request, tmpdir_factory):
 name = request.node.name
 name = re.sub('[\\W]', '_', name)
 MAXVAL = 30
 if (len(name) > MAXVAL):
  name = name[:MAXVAL]
 x = tmpdir_factory.mktemp(name, numbered=True)
 return x

@ pytest . fixture def tmpdir ( request , tmpdir_factory ) : name = request . node . name name = re . sub ( '[\\W]' , '_' , name ) MAXVAL = 30 if ( len ( name ) > MAXVAL ) : name = name [ : MAXVAL ] x = tmpdir_factory . mktemp ( name , numbered = True ) return x
return a temporary directory path object which is unique to each test function invocation .