Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New pytester fixture #7854

Merged
merged 8 commits into from Oct 12, 2020
Merged

Conversation

nicoddemus
Copy link
Member

New pytester fixture with same functionality as testdir, but dealing
with pathlib.Path objects.

Also:

  • Change Testdir to be a thin wrapper which only delegates to PyTester.
  • Convert test_doctest to use test_path and tmp_path.
  • Removed some str() calls now unnecessary given py35 support has been dropped.
  • Use test_path in test_no_brokenpipeerror_message: it uses a private method
    which I don't think we should expose in Testdir for now.

Replaces #7425.

Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Great, LGTM with some comments.

src/_pytest/pytester.py Outdated Show resolved Hide resolved
src/_pytest/pytester.py Outdated Show resolved Hide resolved
src/_pytest/pytester.py Outdated Show resolved Hide resolved
src/_pytest/pytester.py Outdated Show resolved Hide resolved
src/_pytest/pytester.py Outdated Show resolved Hide resolved
src/_pytest/pytester.py Outdated Show resolved Hide resolved
src/_pytest/pytester.py Show resolved Hide resolved
src/_pytest/pytester.py Show resolved Hide resolved
src/_pytest/pytester.py Outdated Show resolved Hide resolved
testing/test_doctest.py Outdated Show resolved Hide resolved
@nicoddemus
Copy link
Member Author

Thanks for the great review @bluetech (I should actually caught many of the problems myself before opening this).

I will get back to this once I have some free time, next weekend at latest. 👍

@nicoddemus nicoddemus self-assigned this Oct 7, 2020
New pytester fixture with same functionality as testdir, but dealing
with pathlib.Path objects.

Also:

* Change Testdir to be a thin wrapper which only delegates to PyTester.
* Convert test_doctest to use test_path and tmp_path.
* Removed some str() calls now unnecessary given py35 support has been dropped.
* Use test_path in test_no_brokenpipeerror_message: it uses a private method
  which I don't think we should expose in Testdir for now.
Copy link
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 absolutely love the overall pr, i wonder if we should provide a plugin with a reverse shim for older pytest / python versions to unblock people porting to the new api even if they are on old python/pytest

It might be a nice hacktober item for someone

src/_pytest/pytester.py Show resolved Hide resolved
src/_pytest/pytester.py Outdated Show resolved Hide resolved
"""Copy file from project's directory into the testdir.

:param str name: The name of the file to copy.
:returns: Path to the copied directory (inside ``self.tmpdir``).
:return: path to the copied directory (inside ``self.path``).

"""
import warnings
from _pytest.warning_types import PYTESTER_COPY_EXAMPLE
Copy link
Member

Choose a reason for hiding this comment

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

I think it can go

src/_pytest/pytester.py Show resolved Hide resolved
Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Left a few minor comments, in addition to a couple previous suggestions

src/_pytest/pytester.py Outdated Show resolved Hide resolved
src/_pytest/pytester.py Outdated Show resolved Hide resolved
src/_pytest/pytester.py Show resolved Hide resolved
src/_pytest/pytester.py Outdated Show resolved Hide resolved
src/_pytest/pytester.py Outdated Show resolved Hide resolved
@nicoddemus
Copy link
Member Author

Anything else @bluetech @RonnyPfannschmidt ?

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.

None yet

3 participants