You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pytest-plugin.md
+53-37Lines changed: 53 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,14 @@
1
1
(pytest_plugin)=
2
2
3
-
# `pytest`plugin
3
+
# `pytest`Plugin
4
4
5
-
Create git, svn, and hg repos on the fly in [pytest].
5
+
With libvcs's pytest plugin for [pytest], you can easily create Git, SVN, and Mercurial repositories on the fly.
6
6
7
-
```{seealso}Using libvcs?
7
+
```{seealso}Are you using libvcs?
8
8
9
-
Do you want more flexibility? Correctness? Power? Defaults changed? [Connect with us] on the tracker, we want to know
10
-
your case, we won't stabilize APIs until we're sure everything is by the book.
9
+
Looking for more flexibility, correctness, or power? Need different defaults? [Connect with us] on GitHub. We'd love to hear about your use case—APIs won't be stabilized until we're confident everything meets expectations.
11
10
12
11
[connect with us]: https://github.com/vcs-python/libvcs/discussions
13
-
14
12
```
15
13
16
14
```{module} libvcs.pytest_plugin
@@ -21,74 +19,92 @@ your case, we won't stabilize APIs until we're sure everything is by the book.
21
19
22
20
## Usage
23
21
24
-
Install `libvcs`via the python package manager of your choosing, e.g.
22
+
Install `libvcs`using your preferred Python package manager:
25
23
26
24
```console
27
25
$ pip install libvcs
28
26
```
29
27
30
-
The pytest plugin will automatically be detected via pytest, and the fixtures will be added.
28
+
Pytest will automatically detect the plugin, and its fixtures will be available.
31
29
32
30
## Fixtures
33
31
34
-
`pytest-vcs` works through providing {ref}`pytest fixtures <pytest:fixtures-api>` - so read up on
35
-
those!
32
+
This pytest plugin works by providing {ref}`pytest fixtures <pytest:fixtures-api>`. The plugin's fixtures ensure that a fresh Git, Subversion, or Mercurial repository is available for each test. It utilizes [session-scoped fixtures] to cache initial repositories, improving performance across tests.
36
33
37
-
The plugin's fixtures guarantee a fresh git repository every test.
_Why aren't these fixtures added automatically by the plugin?_ This design choice promotes explicitness, adhering to best practices for pytest plugins and Python packages.
65
64
66
-
##Bootstrapping pytest in your `conftest.py`
65
+
### Setting a Temporary Home Directory
67
66
68
-
The most common scenario is you will want to configure the above fixtures with `autouse`.
67
+
To set a temporary home directory, use the {func}`set_home` fixture with `autouse=True`:
69
68
70
-
_Why doesn't the plugin automatically add them?_ It's part of being a decent pytest plugin and
71
-
python package: explicitness.
69
+
```python
70
+
import pytest
71
+
72
+
@pytest.fixture(autouse=True)
73
+
defsetup(set_home: None):
74
+
pass
75
+
```
76
+
77
+
### Setting a Default VCS Configuration
78
+
79
+
#### Git
80
+
81
+
Use the {func}`set_gitconfig` fixture with `autouse=True`:
82
+
83
+
```python
84
+
import pytest
85
+
86
+
@pytest.fixture(autouse=True)
87
+
defsetup(set_gitconfig: None):
88
+
pass
89
+
```
72
90
73
-
(set_home)=
91
+
#### Mercurial
74
92
75
-
### Setting a temporary home directory
93
+
Use the {func}`set_hgconfig` fixture with `autouse=True`:
76
94
77
95
```python
78
96
import pytest
79
97
80
98
@pytest.fixture(autouse=True)
81
-
defsetup(
82
-
set_home: None,
83
-
):
99
+
defsetup(set_hgconfig: None):
84
100
pass
85
101
```
86
102
87
-
## See examples
103
+
## Examples
88
104
89
-
View libvcs's own [tests/](https://github.com/vcs-python/libvcs/tree/master/tests)
105
+
For usage examples, refer to libvcs's own [tests/](https://github.com/vcs-python/libvcs/tree/master/tests).
0 commit comments