pathlib Path and py.test LocalPath

前端 未结 2 1082
自闭症患者
自闭症患者 2021-02-20 12:42

I have started using pathlib.Path some time ago and I like using it. Now that I have gotten used to it, I have gotten sloppy and forget to cast arguments to s

2条回答
  •  独厮守ぢ
    2021-02-20 13:26

    In case anyone else is researching whether pytest's tmpdir paths play nicely with pathlib.Path:

    Using python 3.6.5 and pytest 3.2.1, the code posted in the question works perfectly fine without explicitly casting to str:

    from pathlib import Path
    
    def test_tmpdir(tmpdir):
        p = Path(tmpdir) / 'testfile.csv'
    

提交回复
热议问题