Commit 30b66d8d authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #2487 from yan12125/fix-tests-pytest-6.2

Fix tests with pytest 6.2
parents f8096a1f 701eee9e
Fix tests with pytest 6.2
-- by :user:`yan12125`
...@@ -773,7 +773,7 @@ class TestNamespaces: ...@@ -773,7 +773,7 @@ class TestNamespaces:
ns_str = "__import__('pkg_resources').declare_namespace(__name__)\n" ns_str = "__import__('pkg_resources').declare_namespace(__name__)\n"
@pytest.yield_fixture @pytest.fixture
def symlinked_tmpdir(self, tmpdir): def symlinked_tmpdir(self, tmpdir):
""" """
Where available, return the tempdir as a symlink, Where available, return the tempdir as a symlink,
...@@ -791,7 +791,7 @@ class TestNamespaces: ...@@ -791,7 +791,7 @@ class TestNamespaces:
finally: finally:
os.unlink(link_name) os.unlink(link_name)
@pytest.yield_fixture(autouse=True) @pytest.fixture(autouse=True)
def patched_path(self, tmpdir): def patched_path(self, tmpdir):
""" """
Patch sys.path to include the 'site-pkgs' dir. Also Patch sys.path to include the 'site-pkgs' dir. Also
......
...@@ -3,7 +3,7 @@ import pytest ...@@ -3,7 +3,7 @@ import pytest
from . import contexts from . import contexts
@pytest.yield_fixture @pytest.fixture
def user_override(monkeypatch): def user_override(monkeypatch):
""" """
Override site.USER_BASE and site.USER_SITE with temporary directories in Override site.USER_BASE and site.USER_SITE with temporary directories in
...@@ -17,7 +17,7 @@ def user_override(monkeypatch): ...@@ -17,7 +17,7 @@ def user_override(monkeypatch):
yield yield
@pytest.yield_fixture @pytest.fixture
def tmpdir_cwd(tmpdir): def tmpdir_cwd(tmpdir):
with tmpdir.as_cwd() as orig: with tmpdir.as_cwd() as orig:
yield orig yield orig
...@@ -31,7 +31,7 @@ INIT_PY = """print "foo" ...@@ -31,7 +31,7 @@ INIT_PY = """print "foo"
""" """
@pytest.yield_fixture @pytest.fixture
def temp_user(monkeypatch): def temp_user(monkeypatch):
with contexts.tempdir() as user_base: with contexts.tempdir() as user_base:
with contexts.tempdir() as user_site: with contexts.tempdir() as user_site:
...@@ -40,7 +40,7 @@ def temp_user(monkeypatch): ...@@ -40,7 +40,7 @@ def temp_user(monkeypatch):
yield yield
@pytest.yield_fixture @pytest.fixture
def test_env(tmpdir, temp_user): def test_env(tmpdir, temp_user):
target = tmpdir target = tmpdir
foo = target.mkdir('foo') foo = target.mkdir('foo')
......
...@@ -305,7 +305,7 @@ class TestPTHFileWriter: ...@@ -305,7 +305,7 @@ class TestPTHFileWriter:
assert not pth.dirty assert not pth.dirty
@pytest.yield_fixture @pytest.fixture
def setup_context(tmpdir): def setup_context(tmpdir):
with (tmpdir / 'setup.py').open('w') as f: with (tmpdir / 'setup.py').open('w') as f:
f.write(SETUP_PY) f.write(SETUP_PY)
...@@ -361,7 +361,7 @@ class TestUserInstallTest: ...@@ -361,7 +361,7 @@ class TestUserInstallTest:
f.write('Name: foo\n') f.write('Name: foo\n')
return str(tmpdir) return str(tmpdir)
@pytest.yield_fixture() @pytest.fixture()
def install_target(self, tmpdir): def install_target(self, tmpdir):
target = str(tmpdir) target = str(tmpdir)
with mock.patch('sys.path', sys.path + [target]): with mock.patch('sys.path', sys.path + [target]):
...@@ -406,7 +406,7 @@ class TestUserInstallTest: ...@@ -406,7 +406,7 @@ class TestUserInstallTest:
) )
@pytest.yield_fixture @pytest.fixture
def distutils_package(): def distutils_package():
distutils_setup_py = SETUP_PY.replace( distutils_setup_py = SETUP_PY.replace(
'from setuptools import setup', 'from setuptools import setup',
......
...@@ -45,7 +45,7 @@ class TestEggInfo: ...@@ -45,7 +45,7 @@ class TestEggInfo:
""") """)
}) })
@pytest.yield_fixture @pytest.fixture
def env(self): def env(self):
with contexts.tempdir(prefix='setuptools-test.') as env_dir: with contexts.tempdir(prefix='setuptools-test.') as env_dir:
env = Environment(env_dir) env = Environment(env_dir)
......
...@@ -88,7 +88,7 @@ class TestModulePatch: ...@@ -88,7 +88,7 @@ class TestModulePatch:
assert isinstance(exc, expected) assert isinstance(exc, expected)
assert 'aka.ms/vcpython27' in str(exc) assert 'aka.ms/vcpython27' in str(exc)
@pytest.yield_fixture @pytest.fixture
def user_preferred_setting(self): def user_preferred_setting(self):
""" """
Set up environment with different install dirs for user vs. system Set up environment with different install dirs for user vs. system
...@@ -116,7 +116,7 @@ class TestModulePatch: ...@@ -116,7 +116,7 @@ class TestModulePatch:
expected = os.path.join(user_preferred_setting, 'vcvarsall.bat') expected = os.path.join(user_preferred_setting, 'vcvarsall.bat')
assert expected == result assert expected == result
@pytest.yield_fixture @pytest.fixture
def local_machine_setting(self): def local_machine_setting(self):
""" """
Set up environment with only the system environment configured. Set up environment with only the system environment configured.
...@@ -138,7 +138,7 @@ class TestModulePatch: ...@@ -138,7 +138,7 @@ class TestModulePatch:
expected = os.path.join(local_machine_setting, 'vcvarsall.bat') expected = os.path.join(local_machine_setting, 'vcvarsall.bat')
assert expected == result assert expected == result
@pytest.yield_fixture @pytest.fixture
def x64_preferred_setting(self): def x64_preferred_setting(self):
""" """
Set up environment with 64-bit and 32-bit system settings configured Set up environment with 64-bit and 32-bit system settings configured
......
...@@ -5,7 +5,6 @@ import sys ...@@ -5,7 +5,6 @@ import sys
import pathlib import pathlib
import pytest import pytest
from pytest import yield_fixture
from pytest_fixture_config import yield_requires_config from pytest_fixture_config import yield_requires_config
import pytest_virtualenv import pytest_virtualenv
...@@ -29,7 +28,7 @@ def pytest_virtualenv_works(virtualenv): ...@@ -29,7 +28,7 @@ def pytest_virtualenv_works(virtualenv):
@yield_requires_config(pytest_virtualenv.CONFIG, ['virtualenv_executable']) @yield_requires_config(pytest_virtualenv.CONFIG, ['virtualenv_executable'])
@yield_fixture(scope='function') @pytest.fixture(scope='function')
def bare_virtualenv(): def bare_virtualenv():
""" Bare virtualenv (no pip/setuptools/wheel). """ Bare virtualenv (no pip/setuptools/wheel).
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment