pytest-dev / py

Python development support library (note: maintenance only)
MIT License
67 stars 106 forks source link

py.path.local('/x').dirname should be '/' #220

Closed robnagler closed 3 years ago

robnagler commented 5 years ago

dirname should be the same as os.path.dirname and local.dirpath(). Both of these assertions fail:

import os.path
import py
x = py.path.local('/x')
assert x.dirpath() == x.dirname
assert os.path.dirname(str(x)) == x.dirname

dirpath uses os.path.dirname and dirname uses split and join.

RonnyPfannschmidt commented 5 years ago

py.path is correct as per its design and the spec functionality https://github.com/pytest-dev/py/blob/78b8794821e93f625e6d07896b7cfd771ff23fd0/py/_path/local.py#L248-L257

note that your code should use https://github.com/pytest-dev/py/blob/78b8794821e93f625e6d07896b7cfd771ff23fd0/py/_path/common.py#L315-L329 to be correct to begin with

RonnyPfannschmidt commented 3 years ago

closing as not using pylib as intended