2424 import pytest_asyncio
2525
2626 from libvcs .sync ._async .git import AsyncGitSync
27+ from libvcs .sync ._async .hg import AsyncHgSync
28+ from libvcs .sync ._async .svn import AsyncSvnSync
2729
2830 HAS_PYTEST_ASYNCIO = True
2931except ImportError :
@@ -818,10 +820,19 @@ async def async_git_repo(
818820 """
819821 remote_repo_name = unique_repo_name (remote_repos_path = projects_path )
820822 new_checkout_path = projects_path / remote_repo_name
823+ master_copy = remote_repos_path / "async_git_repo"
824+
825+ if master_copy .exists ():
826+ shutil .copytree (master_copy , new_checkout_path )
827+ yield AsyncGitSync (
828+ url = f"file://{ git_remote_repo } " ,
829+ path = new_checkout_path ,
830+ )
831+ return
821832
822833 repo = AsyncGitSync (
823834 url = f"file://{ git_remote_repo } " ,
824- path = new_checkout_path ,
835+ path = master_copy ,
825836 remotes = {
826837 "origin" : GitRemote (
827838 name = "origin" ,
@@ -833,6 +844,81 @@ async def async_git_repo(
833844 await repo .obtain ()
834845 yield repo
835846
847+ @pytest_asyncio .fixture
848+ @skip_if_hg_missing
849+ async def async_hg_repo (
850+ remote_repos_path : pathlib .Path ,
851+ projects_path : pathlib .Path ,
852+ hg_remote_repo : pathlib .Path ,
853+ set_hgconfig : pathlib .Path ,
854+ ) -> t .AsyncGenerator [AsyncHgSync , None ]:
855+ """Pre-made async hg clone of remote repo checked out to user's projects dir.
856+
857+ Async equivalent of :func:`hg_repo` fixture.
858+
859+ Examples
860+ --------
861+ >>> @pytest.mark.asyncio
862+ ... async def test_hg_operations(async_hg_repo):
863+ ... revision = await async_hg_repo.get_revision()
864+ ... assert revision is not None
865+ """
866+ remote_repo_name = unique_repo_name (remote_repos_path = projects_path )
867+ new_checkout_path = projects_path / remote_repo_name
868+ master_copy = remote_repos_path / "async_hg_repo"
869+
870+ if master_copy .exists ():
871+ shutil .copytree (master_copy , new_checkout_path )
872+ yield AsyncHgSync (
873+ url = f"file://{ hg_remote_repo } " ,
874+ path = new_checkout_path ,
875+ )
876+ return
877+
878+ repo = AsyncHgSync (
879+ url = f"file://{ hg_remote_repo } " ,
880+ path = master_copy ,
881+ )
882+ await repo .obtain ()
883+ yield repo
884+
885+ @pytest_asyncio .fixture
886+ @skip_if_svn_missing
887+ async def async_svn_repo (
888+ remote_repos_path : pathlib .Path ,
889+ projects_path : pathlib .Path ,
890+ svn_remote_repo : pathlib .Path ,
891+ ) -> t .AsyncGenerator [AsyncSvnSync , None ]:
892+ """Pre-made async svn checkout of remote repo checked out to user's projects dir.
893+
894+ Async equivalent of :func:`svn_repo` fixture.
895+
896+ Examples
897+ --------
898+ >>> @pytest.mark.asyncio
899+ ... async def test_svn_operations(async_svn_repo):
900+ ... revision = await async_svn_repo.get_revision()
901+ ... assert revision is not None
902+ """
903+ remote_repo_name = unique_repo_name (remote_repos_path = projects_path )
904+ new_checkout_path = projects_path / remote_repo_name
905+ master_copy = remote_repos_path / "async_svn_repo"
906+
907+ if master_copy .exists ():
908+ shutil .copytree (master_copy , new_checkout_path )
909+ yield AsyncSvnSync (
910+ url = f"file://{ svn_remote_repo } " ,
911+ path = new_checkout_path ,
912+ )
913+ return
914+
915+ repo = AsyncSvnSync (
916+ url = f"file://{ svn_remote_repo } " ,
917+ path = master_copy ,
918+ )
919+ await repo .obtain ()
920+ yield repo
921+
836922
837923@pytest .fixture
838924def add_doctest_fixtures (
0 commit comments