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

Appearance settings

Commit a68d632

Browse filesBrowse files
committed
docs(pytest-plugin) Rephrase, note configuration setting fixtures
1 parent 7a8e841 commit a68d632
Copy full SHA for a68d632

File tree

Expand file treeCollapse file tree

1 file changed

+53
-37
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+53
-37
lines changed

‎docs/pytest-plugin.md

Copy file name to clipboardExpand all lines: docs/pytest-plugin.md
+53-37Lines changed: 53 additions & 37 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+
With libvcs's pytest plugin for [pytest], you can easily create Git, SVN, and Mercurial repositories on the fly.
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? 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.
1110
1211
[connect with us]: https://github.com/vcs-python/libvcs/discussions
13-
1412
```
1513

1614
```{module} libvcs.pytest_plugin
@@ -21,74 +19,92 @@ 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+
Pytest will automatically detect the plugin, 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 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.
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+
When the plugin is enabled and `pytest` is run, these fixtures are automatically used:
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
49-
- Patch `$HOME` to point to {func}`user_path` ({func}`set_home`)
45+
- Set the home directory:
46+
- Patch `$HOME` to point to {func}`user_path` using ({func}`set_home`)
5047
- Create configuration files:
48+
- `.gitconfig` via {func}`gitconfig`
49+
- `.hgrc` via {func}`hgconfig`
50+
- Set default VCS configurations:
51+
- Use {func}`hgconfig` for [`HGRCPATH`] via {func}`set_hgconfig`
52+
- Use {func}`gitconfig` for [`GIT_CONFIG`] via {func}`set_gitconfig`
5153

52-
- `.gitconfig`, via {func}`gitconfig`
53-
- `.hgrc`, via {func}`hgconfig`
54+
These ensure that repositories can be cloned and created without unnecessary warnings.
5455

55-
- Set default configuration for VCS:
56+
[`HGRCPATH`]: https://www.mercurial-scm.org/doc/hg.1.html#:~:text=UNIX%2Dlike%20environments.-,HGRCPATH,-If%20not%20set
57+
[`GIT_CONFIG`]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-GITCONFIG
5658

57-
- Set {func}`hgconfig` to [`HGRCPATH`] via {func}`set_hgconfig`
58-
- Set {func}`gitconfig` to [`GIT_CONFIG`] via {func}`set_gitconfig`
59+
## Bootstrapping pytest in `conftest.py`
5960

60-
These are set to ensure you can correctly clone and create repositories without without extra
61-
warnings.
61+
To configure the above fixtures with `autouse=True`, add them to your `conftest.py` file or test file, depending on the desired scope.
6262

63-
[`HGRCPATH`]: https://www.mercurial-scm.org/doc/hg.1.html#:~:text=UNIX%2Dlike%20environments.-,HGRCPATH,-If%20not%20set
64-
[`GIT_CONFIG`]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-GITCONFIG
63+
_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.
6564

66-
## Bootstrapping pytest in your `conftest.py`
65+
### Setting a Temporary Home Directory
6766

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`:
6968

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+
def setup(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+
def setup(set_gitconfig: None):
88+
pass
89+
```
7290

73-
(set_home)=
91+
#### Mercurial
7492

75-
### Setting a temporary home directory
93+
Use the {func}`set_hgconfig` fixture with `autouse=True`:
7694

7795
```python
7896
import pytest
7997

8098
@pytest.fixture(autouse=True)
81-
def setup(
82-
set_home: None,
83-
):
99+
def setup(set_hgconfig: None):
84100
pass
85101
```
86102

87-
## See examples
103+
## Examples
88104

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).
90106

91-
## API reference
107+
## API Reference
92108

93109
```{eval-rst}
94110
.. automodule:: libvcs.pytest_plugin

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.