Closed
Description
I created a repository here to show the bug I am getting:
https://github.com/shuttle1987/pyfakefs-pathlib-fail
Essentially when this test is run:
def test_pathlib(fs): #fs is the fake filesystem fixture
"""Attempt to use a pathlib path"""
import pathlib
base_dir = pathlib.Path('/tmp/corpus_data')
fs.create_dir(base_dir)
from example_lib.searcher import determine_labels
The failure is as follows:
$ python -m pytest
================================================ test session starts ================================================
platform linux -- Python 3.5.2, pytest-3.6.0, py-1.5.3, pluggy-0.6.0
rootdir: /home/janis/pyfakefs-pathlib-fail, inifile:
plugins: cov-2.5.1, pyfakefs-3.4.1
collected 1 item
tests/test_example.py F [100%]
===================================================== FAILURES ======================================================
___________________________________________________ test_pathlib ____________________________________________________
fs = <pyfakefs.fake_filesystem.FakeFilesystem object at 0x7f03fc2b9a90>
> ???
home/janis/pyfakefs-pathlib-fail/tests/test_example.py:6:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
home/janis/pyfakefs-pathlib-fail/venv/lib/python3.5/site-packages/pyfakefs/fake_filesystem.py:2137: in create_dir
???
home/janis/pyfakefs-pathlib-fail/venv/lib/python3.5/site-packages/pyfakefs/fake_filesystem.py:1362: in absnormpath
???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pyfakefs.fake_filesystem.FakeFilesystem object at 0x7f03fc2b9a90>, file_path = PosixPath('/tmp/corpus_data')
> ???
E AttributeError: 'PosixPath' object has no attribute 'startswith'
home/janis/pyfakefs-pathlib-fail/venv/lib/python3.5/site-packages/pyfakefs/fake_filesystem.py:1578: AttributeError
============================================= 1 failed in 0.12 seconds ==============================================
As far as I can tell from reading the documentation this library is supposed to patch pathlib.Path
.