@@ -11,6 +11,7 @@ Features for Git, Subversion, and Mercurial:
11
11
- ** Detect and parse** VCS URLs
12
12
- ** Command** VCS via python API
13
13
- ** Sync** repos locally
14
+ - ** Test fixtures** for temporary local repos and working copies
14
15
15
16
To ** get started** , see the [ quickstart] ( https://libvcs.git-pull.com/quickstart.html ) for more.
16
17
@@ -109,6 +110,43 @@ repo = GitSync(
109
110
u ' 5c227e6ab4aab44bf097da2e088b0ff947370ab8'
110
111
```
111
112
113
+ ## Pytest plugin
114
+
115
+ libvcs also provides a test rig for local repositories. It automatically can provide clean local
116
+ repositories and working copies for git, svn, and mercurial. They are automatically cleaned up after
117
+ each test.
118
+
119
+ It works by bootstrapping a temporary ` $HOME ` environment in a
120
+ [ ` TmpPathFactory ` ] ( https://docs.pytest.org/en/7.1.x/reference/reference.html#tmp-path-factory-factory-api )
121
+ for automatic cleanup.
122
+
123
+ ``` python
124
+ import pathlib
125
+
126
+ from libvcs.pytest_plugin import CreateProjectCallbackFixtureProtocol
127
+ from libvcs.sync.git import GitSync
128
+
129
+
130
+ def test_repo_git_remote_checkout (
131
+ create_git_remote_repo : CreateProjectCallbackFixtureProtocol,
132
+ tmp_path : pathlib.Path,
133
+ projects_path : pathlib.Path,
134
+ ) -> None :
135
+ git_server = create_git_remote_repo()
136
+ git_repo_checkout_dir = projects_path / " my_git_checkout"
137
+ git_repo = GitSync(dir = str (git_repo_checkout_dir), url = f " file:// { git_server!s } " )
138
+
139
+ git_repo.obtain()
140
+ git_repo.update_repo()
141
+
142
+ assert git_repo.get_revision() == " initial"
143
+
144
+ assert git_repo_checkout_dir.exists()
145
+ assert pathlib.Path(git_repo_checkout_dir / " .git" ).exists()
146
+ ```
147
+
148
+ Learn more on the docs at https://libvcs.git-pull.com/pytest-plugin.html
149
+
112
150
## Donations
113
151
114
152
Your donations fund development of new features, testing and support. Your money will go directly to
0 commit comments