Skip to content

Commit b1a8d7a

Browse files
committed
docs(pytest-plugin) Rephrase, note configuration setting fixtures
1 parent 7a8e841 commit b1a8d7a

File tree

1 file changed

+54
-35
lines changed

1 file changed

+54
-35
lines changed

docs/pytest-plugin.md

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
(pytest_plugin)=
22

3-
# `pytest` plugin
3+
# `pytest` Plugin
44

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].
66

7-
```{seealso} Using libvcs?
7+
```{seealso} Are you using libvcs?
88
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.
1110
1211
[connect with us]: https://github.com/vcs-python/libvcs/discussions
13-
1412
```
1513

1614
```{module} libvcs.pytest_plugin
@@ -21,74 +19,95 @@ your case, we won't stabilize APIs until we're sure everything is by the book.
2119

2220
## Usage
2321

24-
Install `libvcs` via the python package manager of your choosing, e.g.
22+
Install `libvcs` using your preferred Python package manager:
2523

2624
```console
2725
$ pip install libvcs
2826
```
2927

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.
3129

3230
## Fixtures
3331

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.
3633

37-
The plugin's fixtures guarantee a fresh git repository every test.
34+
[session-scoped fixtures]: https://docs.pytest.org/en/8.3.x/how-to/fixtures.html#fixture-scopes
3835

3936
(recommended-fixtures)=
4037

41-
## Recommended fixtures
38+
## Recommended Fixtures
4239

43-
These fixtures are automatically used when the plugin is enabled and `pytest` is run.
40+
These fixtures are automatically used when the plugin is enabled and `pytest` is run:
4441

45-
- Creating temporary, test directories for:
42+
- Create temporary test directories for:
4643
- `/home/` ({func}`home_path`)
4744
- `/home/${user}` ({func}`user_path`)
48-
- Setting your home directory
45+
- Set the home directory:
4946
- Patch `$HOME` to point to {func}`user_path` ({func}`set_home`)
5047
- Create configuration files:
48+
- `.gitconfig` via {func}`gitconfig`
49+
- `.hgrc` via {func}`hgconfig`
50+
- Set default VCS configuration:
5151

52-
- `.gitconfig`, via {func}`gitconfig`
53-
- `.hgrc`, via {func}`hgconfig`
54-
55-
- Set default configuration for VCS:
56-
57-
- Set {func}`hgconfig` to [`HGRCPATH`] via {func}`set_hgconfig`
58-
- Set {func}`gitconfig` to [`GIT_CONFIG`] via {func}`set_gitconfig`
52+
- Use {func}`hgconfig` for [`HGRCPATH`] via {func}`set_hgconfig`
53+
- Use {func}`gitconfig` for [`GIT_CONFIG`] via {func}`set_gitconfig`
5954

60-
These are set to ensure you can correctly clone and create repositories without without extra
61-
warnings.
55+
These ensure that repositories can be cloned and created without unnecessary warnings.
6256

6357
[`HGRCPATH`]: https://www.mercurial-scm.org/doc/hg.1.html#:~:text=UNIX%2Dlike%20environments.-,HGRCPATH,-If%20not%20set
6458
[`GIT_CONFIG`]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-GITCONFIG
6559

66-
## Bootstrapping pytest in your `conftest.py`
60+
## Bootstrapping pytest in `conftest.py`
61+
62+
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
6769

68-
The most common scenario is you will want to configure the above fixtures with `autouse`.
70+
```python
71+
import pytest
6972

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+
def setup(set_home: None):
75+
pass
76+
```
7277

7378
(set_home)=
7479

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+
def setup(set_gitconfig: None):
91+
pass
92+
```
93+
94+
#### Mercurial
95+
96+
via {func}`set_hgconfig`:
7697

7798
```python
7899
import pytest
79100

80101
@pytest.fixture(autouse=True)
81-
def setup(
82-
set_home: None,
83-
):
102+
def setup(set_hgconfig: None):
84103
pass
85104
```
86105

87-
## See examples
106+
## Examples
88107

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.
90109

91-
## API reference
110+
## API Reference
92111

93112
```{eval-rst}
94113
.. automodule:: libvcs.pytest_plugin

0 commit comments

Comments
 (0)