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

Fix tests with pytest 6.2 #2487

Merged
merged 1 commit into from Dec 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.d/2487.misc.rst
@@ -0,0 +1,2 @@
Fix tests with pytest 6.2
-- by :user:`yan12125`
4 changes: 2 additions & 2 deletions pkg_resources/tests/test_resources.py
Expand Up @@ -773,7 +773,7 @@ class TestNamespaces:

ns_str = "__import__('pkg_resources').declare_namespace(__name__)\n"

@pytest.yield_fixture
@pytest.fixture
def symlinked_tmpdir(self, tmpdir):
"""
Where available, return the tempdir as a symlink,
Expand All @@ -791,7 +791,7 @@ def symlinked_tmpdir(self, tmpdir):
finally:
os.unlink(link_name)

@pytest.yield_fixture(autouse=True)
@pytest.fixture(autouse=True)
def patched_path(self, tmpdir):
"""
Patch sys.path to include the 'site-pkgs' dir. Also
Expand Down
4 changes: 2 additions & 2 deletions setuptools/tests/fixtures.py
Expand Up @@ -3,7 +3,7 @@
from . import contexts


@pytest.yield_fixture
@pytest.fixture
def user_override(monkeypatch):
"""
Override site.USER_BASE and site.USER_SITE with temporary directories in
Expand All @@ -17,7 +17,7 @@ def user_override(monkeypatch):
yield


@pytest.yield_fixture
@pytest.fixture
def tmpdir_cwd(tmpdir):
with tmpdir.as_cwd() as orig:
yield orig
4 changes: 2 additions & 2 deletions setuptools/tests/test_develop.py
Expand Up @@ -31,7 +31,7 @@
"""


@pytest.yield_fixture
@pytest.fixture
def temp_user(monkeypatch):
with contexts.tempdir() as user_base:
with contexts.tempdir() as user_site:
Expand All @@ -40,7 +40,7 @@ def temp_user(monkeypatch):
yield


@pytest.yield_fixture
@pytest.fixture
def test_env(tmpdir, temp_user):
target = tmpdir
foo = target.mkdir('foo')
Expand Down
6 changes: 3 additions & 3 deletions setuptools/tests/test_easy_install.py
Expand Up @@ -305,7 +305,7 @@ def test_add_from_site_is_ignored(self):
assert not pth.dirty


@pytest.yield_fixture
@pytest.fixture
def setup_context(tmpdir):
with (tmpdir / 'setup.py').open('w') as f:
f.write(SETUP_PY)
Expand Down Expand Up @@ -361,7 +361,7 @@ def foo_package(self, tmpdir):
f.write('Name: foo\n')
return str(tmpdir)

@pytest.yield_fixture()
@pytest.fixture()
def install_target(self, tmpdir):
target = str(tmpdir)
with mock.patch('sys.path', sys.path + [target]):
Expand Down Expand Up @@ -406,7 +406,7 @@ def patched_setup_context(self):
)


@pytest.yield_fixture
@pytest.fixture
def distutils_package():
distutils_setup_py = SETUP_PY.replace(
'from setuptools import setup',
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_egg_info.py
Expand Up @@ -45,7 +45,7 @@ def run():
""")
})

@pytest.yield_fixture
@pytest.fixture
def env(self):
with contexts.tempdir(prefix='setuptools-test.') as env_dir:
env = Environment(env_dir)
Expand Down
6 changes: 3 additions & 3 deletions setuptools/tests/test_msvc.py
Expand Up @@ -88,7 +88,7 @@ def test_no_registry_entries_means_nothing_found(self):
assert isinstance(exc, expected)
assert 'aka.ms/vcpython27' in str(exc)

@pytest.yield_fixture
@pytest.fixture
def user_preferred_setting(self):
"""
Set up environment with different install dirs for user vs. system
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_prefer_current_user(self, user_preferred_setting):
expected = os.path.join(user_preferred_setting, 'vcvarsall.bat')
assert expected == result

@pytest.yield_fixture
@pytest.fixture
def local_machine_setting(self):
"""
Set up environment with only the system environment configured.
Expand All @@ -138,7 +138,7 @@ def test_local_machine_recognized(self, local_machine_setting):
expected = os.path.join(local_machine_setting, 'vcvarsall.bat')
assert expected == result

@pytest.yield_fixture
@pytest.fixture
def x64_preferred_setting(self):
"""
Set up environment with 64-bit and 32-bit system settings configured
Expand Down
3 changes: 1 addition & 2 deletions setuptools/tests/test_virtualenv.py
Expand Up @@ -5,7 +5,6 @@
import pathlib

import pytest
from pytest import yield_fixture
from pytest_fixture_config import yield_requires_config

import pytest_virtualenv
Expand All @@ -29,7 +28,7 @@ def pytest_virtualenv_works(virtualenv):


@yield_requires_config(pytest_virtualenv.CONFIG, ['virtualenv_executable'])
@yield_fixture(scope='function')
@pytest.fixture(scope='function')
def bare_virtualenv():
""" Bare virtualenv (no pip/setuptools/wheel).
"""
Expand Down