Skip to content

Commit 0e3f63c

Browse files
committed
pytest_plugin(refactor[types]): Rename CreateRepoPytestFixtureFn -> CreateRepoFn
why: "PytestFixture" is redundant context inside pytest_plugin.py; the shorter name aligns with the existing Fn-suffix convention used by CreateRepoPostInitFn. what: - Rename Protocol class in src/libvcs/pytest_plugin.py - Update all import sites and type annotations across tests and README.md
1 parent 927d563 commit 0e3f63c

File tree

7 files changed

+47
-47
lines changed

7 files changed

+47
-47
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ Writing a tool that interacts with VCS? Use our fixtures to keep your tests clea
134134

135135
```python
136136
import pathlib
137-
from libvcs.pytest_plugin import CreateRepoPytestFixtureFn
137+
from libvcs.pytest_plugin import CreateRepoFn
138138
from libvcs.sync.git import GitSync
139139

140140
def test_my_git_tool(
141-
create_git_remote_repo: CreateRepoPytestFixtureFn,
141+
create_git_remote_repo: CreateRepoFn,
142142
tmp_path: pathlib.Path
143143
):
144144
# Spin up a real, temporary Git server

src/libvcs/pytest_plugin.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def __call__(
282282
...
283283

284284

285-
class CreateRepoPytestFixtureFn(t.Protocol):
285+
class CreateRepoFn(t.Protocol):
286286
"""Typing for VCS pytest fixture callback."""
287287

288288
def __call__(
@@ -376,7 +376,7 @@ def empty_git_repo(
376376
def create_git_remote_bare_repo(
377377
remote_repos_path: pathlib.Path,
378378
empty_git_bare_repo: pathlib.Path,
379-
) -> CreateRepoPytestFixtureFn:
379+
) -> CreateRepoFn:
380380
"""Return factory to create git remote repo to for clone / push purposes."""
381381

382382
def fn(
@@ -405,7 +405,7 @@ def fn(
405405
def create_git_remote_repo(
406406
remote_repos_path: pathlib.Path,
407407
empty_git_repo: pathlib.Path,
408-
) -> CreateRepoPytestFixtureFn:
408+
) -> CreateRepoFn:
409409
"""Return factory to create git remote repo to for clone / push purposes."""
410410

411411
def fn(
@@ -456,7 +456,7 @@ def git_remote_repo_single_commit_post_init(
456456
@pytest.fixture(scope="session")
457457
@skip_if_git_missing
458458
def git_remote_repo(
459-
create_git_remote_repo: CreateRepoPytestFixtureFn,
459+
create_git_remote_repo: CreateRepoFn,
460460
gitconfig: pathlib.Path,
461461
git_commit_envvars: GitCommitEnvVars,
462462
) -> pathlib.Path:
@@ -543,7 +543,7 @@ def empty_svn_repo(
543543
def create_svn_remote_repo(
544544
remote_repos_path: pathlib.Path,
545545
empty_svn_repo: pathlib.Path,
546-
) -> CreateRepoPytestFixtureFn:
546+
) -> CreateRepoFn:
547547
"""Pre-made svn repo, bare, used as a file:// remote to checkout and commit to."""
548548

549549
def fn(
@@ -573,7 +573,7 @@ def fn(
573573
@pytest.fixture(scope="session")
574574
@skip_if_svn_missing
575575
def svn_remote_repo(
576-
create_svn_remote_repo: CreateRepoPytestFixtureFn,
576+
create_svn_remote_repo: CreateRepoFn,
577577
) -> pathlib.Path:
578578
"""Pre-made. Local file:// based SVN server."""
579579
return create_svn_remote_repo()
@@ -582,7 +582,7 @@ def svn_remote_repo(
582582
@pytest.fixture(scope="session")
583583
@skip_if_svn_missing
584584
def svn_remote_repo_with_files(
585-
create_svn_remote_repo: CreateRepoPytestFixtureFn,
585+
create_svn_remote_repo: CreateRepoFn,
586586
) -> pathlib.Path:
587587
"""Pre-made. Local file:// based SVN server."""
588588
repo_path = create_svn_remote_repo()
@@ -649,7 +649,7 @@ def create_hg_remote_repo(
649649
remote_repos_path: pathlib.Path,
650650
empty_hg_repo: pathlib.Path,
651651
hgconfig: pathlib.Path,
652-
) -> CreateRepoPytestFixtureFn:
652+
) -> CreateRepoFn:
653653
"""Pre-made hg repo, bare, used as a file:// remote to checkout and commit to."""
654654

655655
def fn(
@@ -683,7 +683,7 @@ def fn(
683683
@skip_if_hg_missing
684684
def hg_remote_repo(
685685
remote_repos_path: pathlib.Path,
686-
create_hg_remote_repo: CreateRepoPytestFixtureFn,
686+
create_hg_remote_repo: CreateRepoFn,
687687
hgconfig: pathlib.Path,
688688
) -> pathlib.Path:
689689
"""Pre-made, file-based repo for push and pull."""
@@ -791,9 +791,9 @@ def add_doctest_fixtures(
791791
set_home: pathlib.Path,
792792
git_commit_envvars: GitCommitEnvVars,
793793
hgconfig: pathlib.Path,
794-
create_git_remote_repo: CreateRepoPytestFixtureFn,
795-
create_svn_remote_repo: CreateRepoPytestFixtureFn,
796-
create_hg_remote_repo: CreateRepoPytestFixtureFn,
794+
create_git_remote_repo: CreateRepoFn,
795+
create_svn_remote_repo: CreateRepoFn,
796+
create_hg_remote_repo: CreateRepoFn,
797797
git_repo: pathlib.Path,
798798
) -> None:
799799
"""Harness pytest fixtures to pytest's doctest namespace."""

tests/cmd/test_git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from libvcs.cmd import git
1313

1414
if t.TYPE_CHECKING:
15-
from libvcs.pytest_plugin import CreateRepoPytestFixtureFn, GitCommitEnvVars
15+
from libvcs.pytest_plugin import CreateRepoFn, GitCommitEnvVars
1616
from libvcs.sync.git import GitSync
1717

1818

@@ -956,7 +956,7 @@ class RemoteAddParamFixture(t.NamedTuple):
956956
)
957957
def test_remote_manager_add_params(
958958
git_repo: GitSync,
959-
create_git_remote_repo: CreateRepoPytestFixtureFn,
959+
create_git_remote_repo: CreateRepoFn,
960960
test_id: str,
961961
fetch: bool | None,
962962
track: str | None,

tests/sync/test_git.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
if t.TYPE_CHECKING:
2727
from pytest_mock import MockerFixture
2828

29-
from libvcs.pytest_plugin import CreateRepoPytestFixtureFn
29+
from libvcs.pytest_plugin import CreateRepoFn
3030

3131
if not shutil.which("git"):
3232
pytestmark = pytest.mark.skip(reason="git is not available")
@@ -182,7 +182,7 @@ def test_repo_update_handle_cases(
182182
)
183183
def test_repo_update_stash_cases(
184184
tmp_path: pathlib.Path,
185-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
185+
create_git_remote_bare_repo: CreateRepoFn,
186186
mocker: MockerFixture,
187187
has_untracked_files: bool,
188188
needs_stash: bool,
@@ -551,7 +551,7 @@ def test_remotes_update_repo(
551551
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
552552
lazy_remote_dict: ProjectTestFactoryRemoteLazyExpected,
553553
lazy_remote_expected: ProjectTestFactoryRemoteLazyExpected,
554-
create_git_remote_repo: CreateRepoPytestFixtureFn,
554+
create_git_remote_repo: CreateRepoFn,
555555
) -> None:
556556
"""Tests GitSync with updated remotes."""
557557
repo_name = "myrepo"
@@ -911,7 +911,7 @@ def test_GitRemote__from_stdout_c(fixture: str, expected_result: GitStatus) -> N
911911

912912

913913
def test_repo_git_remote_checkout(
914-
create_git_remote_repo: CreateRepoPytestFixtureFn,
914+
create_git_remote_repo: CreateRepoFn,
915915
tmp_path: pathlib.Path,
916916
projects_path: pathlib.Path,
917917
) -> None:
@@ -930,7 +930,7 @@ def test_repo_git_remote_checkout(
930930

931931

932932
def test_update_repo_success_returns_sync_result(
933-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
933+
create_git_remote_bare_repo: CreateRepoFn,
934934
tmp_path: pathlib.Path,
935935
) -> None:
936936
"""Test that a successful update_repo() returns SyncResult with ok=True."""
@@ -957,7 +957,7 @@ def test_update_repo_success_returns_sync_result(
957957

958958

959959
def test_update_repo_fetch_failure_returns_sync_result(
960-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
960+
create_git_remote_bare_repo: CreateRepoFn,
961961
tmp_path: pathlib.Path,
962962
) -> None:
963963
"""Test that a fetch failure in update_repo() returns SyncResult with error."""
@@ -998,7 +998,7 @@ def test_update_repo_fetch_failure_returns_sync_result(
998998

999999

10001000
def test_update_repo_checkout_failure_returns_sync_result(
1001-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1001+
create_git_remote_bare_repo: CreateRepoFn,
10021002
tmp_path: pathlib.Path,
10031003
) -> None:
10041004
"""Test that a checkout failure in update_repo() returns SyncResult with error."""
@@ -1031,7 +1031,7 @@ def test_update_repo_checkout_failure_returns_sync_result(
10311031

10321032

10331033
def test_update_repo_rev_list_head_failure_returns_sync_result(
1034-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1034+
create_git_remote_bare_repo: CreateRepoFn,
10351035
tmp_path: pathlib.Path,
10361036
) -> None:
10371037
"""update_repo() records rev-list HEAD failure in SyncResult."""
@@ -1065,7 +1065,7 @@ def test_update_repo_rev_list_head_failure_returns_sync_result(
10651065

10661066

10671067
def test_update_repo_submodule_failure_recorded(
1068-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1068+
create_git_remote_bare_repo: CreateRepoFn,
10691069
tmp_path: pathlib.Path,
10701070
mocker: MockerFixture,
10711071
) -> None:
@@ -1118,7 +1118,7 @@ def test_update_repo_submodule_failure_recorded(
11181118

11191119

11201120
def test_update_repo_symbolic_ref_failure_recorded(
1121-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1121+
create_git_remote_bare_repo: CreateRepoFn,
11221122
tmp_path: pathlib.Path,
11231123
) -> None:
11241124
"""Test that symbolic_ref failure on detached HEAD is recorded in SyncResult.
@@ -1158,7 +1158,7 @@ def test_update_repo_symbolic_ref_failure_recorded(
11581158

11591159

11601160
def test_update_repo_remote_ref_not_found_recorded(
1161-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1161+
create_git_remote_bare_repo: CreateRepoFn,
11621162
tmp_path: pathlib.Path,
11631163
) -> None:
11641164
"""Test that GitRemoteRefNotFound is caught and recorded in SyncResult.
@@ -1200,7 +1200,7 @@ def test_update_repo_remote_ref_not_found_recorded(
12001200

12011201

12021202
def test_update_repo_obtain_failure_recorded(
1203-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1203+
create_git_remote_bare_repo: CreateRepoFn,
12041204
tmp_path: pathlib.Path,
12051205
mocker: MockerFixture,
12061206
) -> None:
@@ -1237,7 +1237,7 @@ def test_update_repo_obtain_failure_recorded(
12371237

12381238

12391239
def test_update_repo_set_remotes_failure_recorded(
1240-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1240+
create_git_remote_bare_repo: CreateRepoFn,
12411241
tmp_path: pathlib.Path,
12421242
mocker: MockerFixture,
12431243
) -> None:
@@ -1281,7 +1281,7 @@ def test_update_repo_set_remotes_failure_recorded(
12811281

12821282

12831283
def test_update_repo_remote_name_failure_recorded(
1284-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1284+
create_git_remote_bare_repo: CreateRepoFn,
12851285
tmp_path: pathlib.Path,
12861286
mocker: MockerFixture,
12871287
) -> None:
@@ -1324,7 +1324,7 @@ def test_update_repo_remote_name_failure_recorded(
13241324

13251325

13261326
def test_update_repo_status_failure_recorded(
1327-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1327+
create_git_remote_bare_repo: CreateRepoFn,
13281328
tmp_path: pathlib.Path,
13291329
mocker: MockerFixture,
13301330
) -> None:
@@ -1385,7 +1385,7 @@ def status_side_effect(**kwargs: t.Any) -> str:
13851385

13861386

13871387
def test_update_repo_stash_save_failure_recorded(
1388-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1388+
create_git_remote_bare_repo: CreateRepoFn,
13891389
tmp_path: pathlib.Path,
13901390
mocker: MockerFixture,
13911391
) -> None:
@@ -1451,7 +1451,7 @@ def status_side_effect(**kwargs: t.Any) -> str:
14511451

14521452

14531453
def test_update_repo_rebase_invalid_upstream_recorded(
1454-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1454+
create_git_remote_bare_repo: CreateRepoFn,
14551455
tmp_path: pathlib.Path,
14561456
mocker: MockerFixture,
14571457
) -> None:
@@ -1519,7 +1519,7 @@ def status_side_effect(**kwargs: t.Any) -> str:
15191519

15201520

15211521
def test_update_repo_rebase_conflict_recorded(
1522-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1522+
create_git_remote_bare_repo: CreateRepoFn,
15231523
tmp_path: pathlib.Path,
15241524
mocker: MockerFixture,
15251525
) -> None:
@@ -1587,7 +1587,7 @@ def status_side_effect(**kwargs: t.Any) -> str:
15871587

15881588

15891589
def test_update_repo_stash_pop_failure_recorded(
1590-
create_git_remote_bare_repo: CreateRepoPytestFixtureFn,
1590+
create_git_remote_bare_repo: CreateRepoFn,
15911591
tmp_path: pathlib.Path,
15921592
mocker: MockerFixture,
15931593
) -> None:

tests/sync/test_hg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from libvcs.sync.hg import HgSync
1717

1818
if t.TYPE_CHECKING:
19-
from libvcs.pytest_plugin import CreateRepoPytestFixtureFn
19+
from libvcs.pytest_plugin import CreateRepoFn
2020

2121
if not shutil.which("hg"):
2222
pytestmark = pytest.mark.skip(reason="hg is not available")
@@ -113,7 +113,7 @@ def test_vulnerability_2022_03_12_command_injection(
113113

114114
def test_update_repo_pull_failure_returns_sync_result(
115115
projects_path: pathlib.Path,
116-
create_hg_remote_repo: CreateRepoPytestFixtureFn,
116+
create_hg_remote_repo: CreateRepoFn,
117117
) -> None:
118118
"""Test that a deleted remote in update_repo() returns SyncResult with error."""
119119
repo_name = "my_hg_error_project"

tests/sync/test_svn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
if t.TYPE_CHECKING:
1515
import pathlib
1616

17-
from libvcs.pytest_plugin import CreateRepoPytestFixtureFn
17+
from libvcs.pytest_plugin import CreateRepoFn
1818

1919
if not shutil.which("svn"):
2020
pytestmark = pytest.mark.skip(reason="svn is not available")
@@ -60,7 +60,7 @@ def test_svn_sync_with_files(
6060

6161

6262
def test_repo_svn_remote_checkout(
63-
create_svn_remote_repo: CreateRepoPytestFixtureFn,
63+
create_svn_remote_repo: CreateRepoFn,
6464
tmp_path: pathlib.Path,
6565
projects_path: pathlib.Path,
6666
) -> None:
@@ -79,7 +79,7 @@ def test_repo_svn_remote_checkout(
7979

8080

8181
def test_update_repo_checkout_failure_returns_sync_result(
82-
create_svn_remote_repo: CreateRepoPytestFixtureFn,
82+
create_svn_remote_repo: CreateRepoFn,
8383
tmp_path: pathlib.Path,
8484
projects_path: pathlib.Path,
8585
) -> None:

0 commit comments

Comments
 (0)