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
+54-35Lines changed: 54 additions & 35 deletions
Display the source diff
Display the rich diff
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
+
Easily create Git, SVN, and Mercurial repositories on the fly with[pytest].
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? Want different defaults? [Connect with us] on GitHub. We want to hear about your use case—APIs won't be stabilized until we ensure everything is by the book.
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,95 @@ 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
+
The pytest plugin is automatically detected by pytest, 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 a fresh Git, Subversion, or Mercurial repository can be available on each test. It makes use of [session-scoped fixtures] to catch initial repositories for improve performance across tests.
36
33
37
-
The plugin's fixtures guarantee a fresh git repository every test.
To configure the above fixtures with `autouse`, add them to your `conftest.py` file or test file, depending on what scope you want the fixture to take effect.
63
+
64
+
_Why aren't they added automatically by the plugin?_ This ensures explicitness, adhering to best practices for pytest plugins and Python packages.
65
+
66
+
(set_home)=
67
+
68
+
### Setting a Temporary Home Directory
67
69
68
-
The most common scenario is you will want to configure the above fixtures with `autouse`.
70
+
```python
71
+
import pytest
69
72
70
-
_Why doesn't the plugin automatically add them?_ It's part of being a decent pytest plugin and
71
-
python package: explicitness.
73
+
@pytest.fixture(autouse=True)
74
+
defsetup(set_home: None):
75
+
pass
76
+
```
72
77
73
78
(set_home)=
74
79
75
-
### Setting a temporary home directory
80
+
### Setting a default VCS configuration
81
+
82
+
#### Git
83
+
84
+
via {func}`set_gitconfig`:
85
+
86
+
```python
87
+
import pytest
88
+
89
+
@pytest.fixture(autouse=True)
90
+
defsetup(set_gitconfig: None):
91
+
pass
92
+
```
93
+
94
+
#### Mercurial
95
+
96
+
via {func}`set_hgconfig`:
76
97
77
98
```python
78
99
import pytest
79
100
80
101
@pytest.fixture(autouse=True)
81
-
defsetup(
82
-
set_home: None,
83
-
):
102
+
defsetup(set_hgconfig: None):
84
103
pass
85
104
```
86
105
87
-
## See examples
106
+
## Examples
88
107
89
-
View libvcs's own [tests/](https://github.com/vcs-python/libvcs/tree/master/tests)
108
+
View libvcs's own [tests/](https://github.com/vcs-python/libvcs/tree/master/tests) for usage examples.
0 commit comments