Skip to content

Commit b8f1c9e

Browse files
committed
refactor(conftest): Remove unused fixtures in favor of libvcs plugin
1 parent 94db3b0 commit b8f1c9e

File tree

1 file changed

+25
-51
lines changed

1 file changed

+25
-51
lines changed

tests/conftest.py

Lines changed: 25 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
1-
import getpass
21
import pathlib
32
import shutil
4-
import textwrap
3+
import typing as t
54

65
import pytest
76

87

9-
@pytest.fixture(autouse=True, scope="session")
10-
def home_path(tmp_path_factory: pytest.TempPathFactory):
11-
return tmp_path_factory.mktemp("home")
8+
@pytest.fixture(autouse=True)
9+
def add_doctest_fixtures(
10+
request: pytest.FixtureRequest,
11+
doctest_namespace: t.Dict[str, t.Any],
12+
) -> None:
13+
from _pytest.doctest import DoctestItem
1214

15+
if isinstance(request._pyfuncitem, DoctestItem):
16+
request.getfixturevalue("add_doctest_fixtures")
17+
request.getfixturevalue("set_home")
18+
19+
20+
@pytest.fixture(autouse=True)
21+
def setup(
22+
request: pytest.FixtureRequest,
23+
gitconfig: pathlib.Path,
24+
set_home: pathlib.Path,
25+
xdg_config_path: pathlib.Path,
26+
) -> None:
27+
pass
1328

14-
@pytest.fixture(autouse=True, scope="session")
15-
def user_path(home_path: pathlib.Path):
16-
p = home_path / getpass.getuser()
17-
p.mkdir()
18-
return p
29+
30+
@pytest.fixture(autouse=True)
31+
def cwd_default(monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path) -> None:
32+
monkeypatch.chdir(tmp_path)
1933

2034

2135
@pytest.fixture(autouse=True, scope="session")
22-
@pytest.mark.usefixtures("set_user_path")
36+
@pytest.mark.usefixtures("set_home")
2337
def xdg_config_path(user_path: pathlib.Path):
2438
p = user_path / ".config"
2539
p.mkdir()
@@ -38,11 +52,6 @@ def clean():
3852
return conf_path
3953

4054

41-
@pytest.fixture(autouse=True)
42-
def set_user_path(monkeypatch: pytest.MonkeyPatch, user_path: pathlib.Path):
43-
monkeypatch.setenv("HOME", str(user_path))
44-
45-
4655
@pytest.fixture(autouse=True)
4756
def set_xdg_config_path(monkeypatch: pytest.MonkeyPatch, xdg_config_path: pathlib.Path):
4857
monkeypatch.setenv("XDG_CONFIG_HOME", str(xdg_config_path))
@@ -59,38 +68,3 @@ def clean():
5968

6069
request.addfinalizer(clean)
6170
return dir
62-
63-
64-
@pytest.fixture(autouse=True, scope="session")
65-
def hgrc(user_path: pathlib.Path):
66-
hgrc = user_path / ".hgrc"
67-
hgrc.write_text(
68-
textwrap.dedent(
69-
f"""
70-
[ui]
71-
username = vcspull tests <vcspull@git-pull.com>
72-
merge = internal:merge
73-
74-
[trusted]
75-
users = {getpass.getuser()}
76-
"""
77-
),
78-
encoding="utf-8",
79-
)
80-
return hgrc
81-
82-
83-
@pytest.fixture(autouse=True, scope="module")
84-
def gitconfig(user_path: pathlib.Path):
85-
gitconfig = user_path / ".gitconfig"
86-
gitconfig.write_text(
87-
textwrap.dedent(
88-
f"""
89-
[user]
90-
email = libvcs@git-pull.com
91-
name = {getpass.getuser()}
92-
"""
93-
),
94-
encoding="utf-8",
95-
)
96-
return gitconfig

0 commit comments

Comments
 (0)