Skip to content

Some py.path.local -> pathlib.Path#8122

Merged
bluetech merged 1 commit intopytest-dev:masterfrom
bluetech:py-to-pathlib-3
Dec 13, 2020
Merged

Some py.path.local -> pathlib.Path#8122
bluetech merged 1 commit intopytest-dev:masterfrom
bluetech:py-to-pathlib-3

Conversation

@bluetech
Copy link
Copy Markdown
Member

  • Some conftest related functions
  • Config._confcutdir
  • Allow arbitrary os.PathLike[str] in gethookproxy.

Copy link
Copy Markdown
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i love what you did there 👍

- Some conftest related functions
- _confcutdir
- Allow arbitrary os.PathLike[str] in gethookproxy.
@bluetech bluetech merged commit 37b154b into pytest-dev:master Dec 13, 2020
@bluetech bluetech deleted the py-to-pathlib-3 branch December 15, 2020 11:14
@pllim
Copy link
Copy Markdown
Contributor

pllim commented Dec 15, 2020

Hello. We think that this PR broke pytest-doctestplus plugin downstream. Example log: https://github.com/astropy/pytest-doctestplus/pull/139/checks?check_run_id=1558353239 . Not sure if the breakage is intentional. Any advice would be greatly appreciated. Thanks!

cc @saimn

@nicoddemus
Copy link
Copy Markdown
Member

Hi @pllim,

This PR refactored some internal code, I see pytest_doctestplus/plugin.py:437 calls _getconftest_pathlist:

/Users/runner/work/pytest-doctestplus/pytest-doctestplus/.tox/py38-test-pytestdev/lib/python3.8/site-packages/pytest_doctestplus/plugin.py:437: in pytest_ignore_collect
    collect_ignore = config._getconftest_pathlist("collect_ignore", path=path.dirpath())

This PR changed that path parameter from py.path.local to Path.

I believe changing that line to:

    collect_ignore = config._getconftest_pathlist("collect_ignore", path=Path(path).parent)

Should fix that issue. 👍

@pllim
Copy link
Copy Markdown
Contributor

pllim commented Dec 15, 2020

Hmm... now it fails here:

______________________ ERROR collecting tests/conftest.py ______________________
../../.tox/py38-test-pytestdev/lib/python3.8/site-packages/pytest_doctestplus/plugin.py:196: in collect
    module = self.config.pluginmanager._importconftest(
../../.tox/py38-test-pytestdev/lib/python3.8/site-packages/_pytest/config/__init__.py:560: in _importconftest
    key = conftestpath.resolve()
E   AttributeError: 'LocalPath' object has no attribute 'resolve'

scientific-python/pytest-doctestplus#140

UPDATE: Looks like forcing self.fspath to be Path before passing it into _importconftest works but hopefully not too hacky.

@nicoddemus
Copy link
Copy Markdown
Member

UPDATE: Looks like forcing self.fspath to be Path before passing it into _importconftest works but hopefully not too hacky.

No, that's the correct approach.

Some background: we are in the process of changing internal functions to use Path instead of py.path.local, with the long term goal of eventually deprecating/removing the dependency to the py library. While we try to shield those changes from end users, changing the actual internal functions is unavoidable, so this unfortunately will have consequences to plugins which call internal functions (and we understand there are many situations where there are no other options other than call those internal functions).

We are sorry for the disruption that this might cause, but please bear with us. 👍

@pllim
Copy link
Copy Markdown
Contributor

pllim commented Dec 15, 2020

No worries and thanks for the timely help, @nicoddemus !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants