Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 02b87ec

Browse files
committed
1 parent 10c8061 commit 02b87ec

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

‎.cursor/rules/vcspull-pytest.mdc‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
description:
3+
globs: tests/**/test_*.py
4+
alwaysApply: true
5+
---
6+
7+
# VCSPull Pytest Integration with libvcs
8+
9+
When writing tests for vcspull, leverage libvcs's pytest plugin to efficiently create and manage VCS repositories during testing.
10+
11+
## Available Fixtures from libvcs
12+
13+
libvcs provides a complete set of fixtures that automatically handle the creation and cleanup of VCS repositories:
14+
15+
### Core Repository Creation Fixtures
16+
17+
- `create_git_remote_repo`: Factory fixture that creates a local Git repository
18+
- `create_svn_remote_repo`: Factory fixture that creates a local SVN repository
19+
- `create_hg_remote_repo`: Factory fixture that creates a local Mercurial repository
20+
21+
### Pre-configured Repository Fixtures
22+
23+
- `git_repo`: Pre-made Git repository clone (GitSync instance)
24+
- `svn_repo`: Pre-made SVN repository checkout (SvnSync instance)
25+
- `hg_repo`: Pre-made Mercurial repository clone (HgSync instance)
26+
27+
### Environment & Configuration Fixtures
28+
29+
- `set_home`: Sets a temporary home directory
30+
- `gitconfig`: Git configuration for test repositories
31+
- `hgconfig`: Mercurial configuration for test repositories
32+
- `git_commit_envvars`: Environment variables for Git commits
33+
34+
## Usage Examples
35+
36+
### Basic Repository Creation
37+
38+
```python
39+
def test_vcspull_with_git(create_git_remote_repo):
40+
# Create a test git repository on-the-fly
41+
repo_path = create_git_remote_repo()
42+
43+
# repo_path is now a pathlib.Path pointing to a clean git repo
44+
# Use this repository in your vcspull tests
45+
```
46+
47+
### Using Pre-configured Repositories
48+
49+
```python
50+
def test_vcspull_sync(git_repo):
51+
# git_repo is already a GitSync instance with a clean repository
52+
# Use it directly in your tests
53+
54+
# The repository will be automatically cleaned up after the test
55+
```
56+
57+
### Custom Repository Setup
58+
59+
```python
60+
def test_custom_repo_state(
61+
create_git_remote_repo,
62+
git_commit_envvars
63+
):
64+
# Create a repo with custom initialization
65+
repo_path = create_git_remote_repo()
66+
67+
# Modify the repository as needed with the correct environment
68+
import subprocess
69+
subprocess.run(
70+
["git", "commit", "--allow-empty", "-m", "Custom commit"],
71+
cwd=repo_path,
72+
env=git_commit_envvars
73+
)
74+
```
75+
76+
## Benefits
77+
78+
- **Fast tests**: Repositories are created efficiently and cached appropriately
79+
- **Clean environment**: Each test gets fresh repositories without interference
80+
- **Reduced boilerplate**: No need to manually create/clean up repositories
81+
- **Realistic testing**: Test against actual VCS operations
82+
- **Compatible with pytest-xdist**: Works correctly with parallel test execution
83+
84+
For detailed documentation on all available fixtures, visit:
85+
- https://libvcs.git-pull.com/pytest-plugin.html
86+
- https://github.com/vcs-python/libvcs/blob/master/src/libvcs/pytest_plugin.py

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /