From 4f5c153d29eb91a76e8f2aa519684e9710ef6624 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 21 Nov 2018 20:46:08 -0200 Subject: [PATCH] Fix call to os.path.abspath: the argument might already be a Path instance There's Path.absolute(), but it is not public, see https://bugs.python.org/issue25012. --- src/_pytest/tmpdir.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index 937d90c2f..dadb196ea 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -10,6 +10,7 @@ import warnings import attr import py +import six import pytest from .pathlib import ensure_reset_dir @@ -28,8 +29,11 @@ class TempPathFactory(object): _given_basetemp = attr.ib( # using os.path.abspath() to get absolute path instead of resolve() as it - # does not work the same in all platforms - convert=attr.converters.optional(lambda p: Path(os.path.abspath(p))) + # does not work the same in all platforms; there's Path.absolute(), but it is not + # public (see https://bugs.python.org/issue25012) + convert=attr.converters.optional( + lambda p: Path(os.path.abspath(six.text_type(p))) + ) ) _trace = attr.ib() _basetemp = attr.ib(default=None)