1414
1515import pytest
1616import yaml
17+ from libvcs .pytest_plugin import (
18+ hg_remote_repo_single_commit_post_init ,
19+ svn_remote_repo_single_commit_post_init ,
20+ )
1721
1822from vcspull .__about__ import __version__
1923from vcspull ._internal .private_path import PrivatePath
2832if t .TYPE_CHECKING :
2933 from typing import TypeAlias
3034
35+ from libvcs .pytest_plugin import CreateRepoPytestFixtureFn
3136 from libvcs .sync .git import GitSync
3237
3338 ExpectedOutput : TypeAlias = str | list [str ] | None
@@ -935,8 +940,6 @@ class SyncErroredSvnRepoFixture(t.NamedTuple):
935940]
936941
937942
938- @pytest .mark .skipif (not shutil .which ("svn" ), reason = "svn not installed" )
939- @pytest .mark .skipif (not shutil .which ("svnadmin" ), reason = "svnadmin not installed" )
940943@pytest .mark .parametrize (
941944 list (SyncErroredSvnRepoFixture ._fields ),
942945 SYNC_ERRORED_SVN_REPO_FIXTURES ,
@@ -948,6 +951,7 @@ def test_sync_errored_svn_repo(
948951 monkeypatch : pytest .MonkeyPatch ,
949952 user_path : pathlib .Path ,
950953 config_path : pathlib .Path ,
954+ create_svn_remote_repo : CreateRepoPytestFixtureFn ,
951955 test_id : str ,
952956 sync_args : list [str ],
953957 expected_in_out : ExpectedOutput ,
@@ -961,35 +965,11 @@ def test_sync_errored_svn_repo(
961965 then deletes the SVN repository and verifies that the next sync
962966 reports the failure instead of silently succeeding.
963967 """
964- import subprocess
965-
966- # Create an SVN repository
967- svn_remote_dir = tmp_path / "svn_remote"
968- subprocess .run (
969- ["svnadmin" , "create" , str (svn_remote_dir )],
970- check = True ,
971- capture_output = True ,
972- )
973-
974- # Import initial content into the SVN repo
975- import_dir = tmp_path / "svn_import"
976- import_dir .mkdir ()
977- (import_dir / "initial.txt" ).write_text ("init" , encoding = "utf-8" )
978- subprocess .run (
979- [
980- "svn" ,
981- "import" ,
982- str (import_dir ),
983- f"file://{ svn_remote_dir } /trunk" ,
984- "-m" ,
985- "initial import" ,
986- ],
987- check = True ,
988- capture_output = True ,
968+ # Use libvcs factory fixture to create an SVN remote with initial content
969+ svn_remote_dir = create_svn_remote_repo (
970+ remote_repo_post_init = svn_remote_repo_single_commit_post_init ,
989971 )
990- shutil .rmtree (import_dir )
991-
992- svn_url = f"svn+file://{ svn_remote_dir } /trunk"
972+ svn_url = f"svn+file://{ svn_remote_dir } "
993973
994974 github_projects = user_path / "github_projects"
995975 config : dict [str , dict [str , dict [str , t .Any ]]] = {
@@ -1076,7 +1056,6 @@ class SyncErroredHgRepoFixture(t.NamedTuple):
10761056]
10771057
10781058
1079- @pytest .mark .skipif (not shutil .which ("hg" ), reason = "hg not installed" )
10801059@pytest .mark .parametrize (
10811060 list (SyncErroredHgRepoFixture ._fields ),
10821061 SYNC_ERRORED_HG_REPO_FIXTURES ,
@@ -1088,6 +1067,7 @@ def test_sync_errored_hg_repo(
10881067 monkeypatch : pytest .MonkeyPatch ,
10891068 user_path : pathlib .Path ,
10901069 config_path : pathlib .Path ,
1070+ create_hg_remote_repo : CreateRepoPytestFixtureFn ,
10911071 test_id : str ,
10921072 sync_args : list [str ],
10931073 expected_in_out : ExpectedOutput ,
@@ -1101,30 +1081,10 @@ def test_sync_errored_hg_repo(
11011081 then deletes the repository and verifies that the next sync
11021082 reports the failure instead of silently succeeding.
11031083 """
1104- import subprocess
1105-
1106- monkeypatch .setenv ("HGUSER" , "Test User <test@test.com>" )
1107-
1108- # Create an HG repository
1109- hg_remote_dir = tmp_path / "hg_remote"
1110- hg_remote_dir .mkdir ()
1111- subprocess .run (["hg" , "init" ], cwd = hg_remote_dir , check = True , capture_output = True )
1112-
1113- # Add initial content
1114- (hg_remote_dir / "initial.txt" ).write_text ("init" , encoding = "utf-8" )
1115- subprocess .run (
1116- ["hg" , "add" , "initial.txt" ],
1117- cwd = hg_remote_dir ,
1118- check = True ,
1119- capture_output = True ,
1084+ # Use libvcs factory fixture to create an HG remote with initial content
1085+ hg_remote_dir = create_hg_remote_repo (
1086+ remote_repo_post_init = hg_remote_repo_single_commit_post_init ,
11201087 )
1121- subprocess .run (
1122- ["hg" , "commit" , "-m" , "initial commit" ],
1123- cwd = hg_remote_dir ,
1124- check = True ,
1125- capture_output = True ,
1126- )
1127-
11281088 hg_url = f"hg+file://{ hg_remote_dir } "
11291089
11301090 github_projects = user_path / "github_projects"
0 commit comments