pathlib Path and py.test LocalPath

前端 未结 2 1033
自闭症患者
自闭症患者 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

    That last one (wrapping) should work, I suspect you actually test all of these in one py.test/tox run and that monkey-patch is still in effect (that might explain why it worked at some point, the order of the test files etc matters if you start to change things on global classes).

    That this is hard, is because of Path essentially being a generator, that on the fly decides whether you are on Windows or Linux, and creates a WindowsPath resp. PosixPath accordingly.

    BDFL Guido van Rossum already indicated in May 2015:

    It does sound like subclassing Path should be made easier.

    but nothing happened. Support for pathlib in 3.6 within other standard libraries has increased, but pathlib itself still has the same problems.

提交回复
热议问题