Skip to content

Commit 30b66d8

Browse files
authored
Merge pull request #2487 from yan12125/fix-tests-pytest-6.2
Fix tests with pytest 6.2
2 parents f8096a1 + 701eee9 commit 30b66d8

File tree

8 files changed

+16
-15
lines changed

8 files changed

+16
-15
lines changed

changelog.d/2487.misc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix tests with pytest 6.2
2+
-- by :user:`yan12125`

pkg_resources/tests/test_resources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ class TestNamespaces:
773773

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

776-
@pytest.yield_fixture
776+
@pytest.fixture
777777
def symlinked_tmpdir(self, tmpdir):
778778
"""
779779
Where available, return the tempdir as a symlink,
@@ -791,7 +791,7 @@ def symlinked_tmpdir(self, tmpdir):
791791
finally:
792792
os.unlink(link_name)
793793

794-
@pytest.yield_fixture(autouse=True)
794+
@pytest.fixture(autouse=True)
795795
def patched_path(self, tmpdir):
796796
"""
797797
Patch sys.path to include the 'site-pkgs' dir. Also

setuptools/tests/fixtures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from . import contexts
44

55

6-
@pytest.yield_fixture
6+
@pytest.fixture
77
def user_override(monkeypatch):
88
"""
99
Override site.USER_BASE and site.USER_SITE with temporary directories in
@@ -17,7 +17,7 @@ def user_override(monkeypatch):
1717
yield
1818

1919

20-
@pytest.yield_fixture
20+
@pytest.fixture
2121
def tmpdir_cwd(tmpdir):
2222
with tmpdir.as_cwd() as orig:
2323
yield orig

setuptools/tests/test_develop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"""
3232

3333

34-
@pytest.yield_fixture
34+
@pytest.fixture
3535
def temp_user(monkeypatch):
3636
with contexts.tempdir() as user_base:
3737
with contexts.tempdir() as user_site:
@@ -40,7 +40,7 @@ def temp_user(monkeypatch):
4040
yield
4141

4242

43-
@pytest.yield_fixture
43+
@pytest.fixture
4444
def test_env(tmpdir, temp_user):
4545
target = tmpdir
4646
foo = target.mkdir('foo')

setuptools/tests/test_easy_install.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def test_add_from_site_is_ignored(self):
305305
assert not pth.dirty
306306

307307

308-
@pytest.yield_fixture
308+
@pytest.fixture
309309
def setup_context(tmpdir):
310310
with (tmpdir / 'setup.py').open('w') as f:
311311
f.write(SETUP_PY)
@@ -361,7 +361,7 @@ def foo_package(self, tmpdir):
361361
f.write('Name: foo\n')
362362
return str(tmpdir)
363363

364-
@pytest.yield_fixture()
364+
@pytest.fixture()
365365
def install_target(self, tmpdir):
366366
target = str(tmpdir)
367367
with mock.patch('sys.path', sys.path + [target]):
@@ -406,7 +406,7 @@ def patched_setup_context(self):
406406
)
407407

408408

409-
@pytest.yield_fixture
409+
@pytest.fixture
410410
def distutils_package():
411411
distutils_setup_py = SETUP_PY.replace(
412412
'from setuptools import setup',

setuptools/tests/test_egg_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def run():
4545
""")
4646
})
4747

48-
@pytest.yield_fixture
48+
@pytest.fixture
4949
def env(self):
5050
with contexts.tempdir(prefix='setuptools-test.') as env_dir:
5151
env = Environment(env_dir)

setuptools/tests/test_msvc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_no_registry_entries_means_nothing_found(self):
8888
assert isinstance(exc, expected)
8989
assert 'aka.ms/vcpython27' in str(exc)
9090

91-
@pytest.yield_fixture
91+
@pytest.fixture
9292
def user_preferred_setting(self):
9393
"""
9494
Set up environment with different install dirs for user vs. system
@@ -116,7 +116,7 @@ def test_prefer_current_user(self, user_preferred_setting):
116116
expected = os.path.join(user_preferred_setting, 'vcvarsall.bat')
117117
assert expected == result
118118

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

141-
@pytest.yield_fixture
141+
@pytest.fixture
142142
def x64_preferred_setting(self):
143143
"""
144144
Set up environment with 64-bit and 32-bit system settings configured

setuptools/tests/test_virtualenv.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pathlib
66

77
import pytest
8-
from pytest import yield_fixture
98
from pytest_fixture_config import yield_requires_config
109

1110
import pytest_virtualenv
@@ -29,7 +28,7 @@ def pytest_virtualenv_works(virtualenv):
2928

3029

3130
@yield_requires_config(pytest_virtualenv.CONFIG, ['virtualenv_executable'])
32-
@yield_fixture(scope='function')
31+
@pytest.fixture(scope='function')
3332
def bare_virtualenv():
3433
""" Bare virtualenv (no pip/setuptools/wheel).
3534
"""

0 commit comments

Comments
 (0)