Skip to content

Commit b8c2252

Browse files
author
Martin Møldrup
committed
Update markdown
1 parent 2c7610f commit b8c2252

File tree

4 files changed

+28
-41
lines changed

4 files changed

+28
-41
lines changed

CHANGELOG.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
11
# Change log
22
All notable changes to this project will be documented in this file.
3-
## [0.2.1]
3+
4+
*NOTE:* Version 0.X.X might have breaking changes in bumps of the minor version number. This is because the project is still in early development and the API is not yet stable. It will still be marked clearly in the release notes.
5+
6+
## [0.3.0]
7+
- Add snappylapy parametization functionality to snappylapy and allow it to be loaded in the load_snapshot fixture
8+
- Do reporting showing count of updated, created and deleted snapshots
9+
- **Breaking Changes**
10+
- Change setting of path to only have a single path configurable and update such it is configured through the marker
11+
- Make the folder names of __snapshots__ and __test_results__ enforced to be fixed (needed for cleanup and diffing)
12+
- Rename output file names of snapshots to match [filename][testname][name].extention conversion
13+
14+
## [0.2.1] - 13-01-2025
415
- Added missing dependency for typer to make the CLI work
516

6-
## [0.2.0]
17+
## [0.2.0] - 13-01-2025
718
- Better error messages by using pytest assertion rewriting
819
- Allow users to set the snapshot directory when using the load_snapshot fixture
920
- Add CLI for for init and clear commands
1021
- Added automated generation of documentation using mkdocs
1122

12-
## [0.1.1]
23+
## [0.1.1] - 10-01-2025
1324
- Update dependencies with the lower bounds of package compatibility
1425
- Refactor to make code easier for users of package to modify and extend
1526

16-
## [0.1.0]
27+
## [0.1.0] - 08-01-2025
1728
- Added fixture for loading snapshots from previous tests (load_snapshot fixture)
1829
- Added the snappylapy marker for tests that depend on previous tests (pytest.mark.snappylapy). This will be used for more advanced features in the future.
1930

20-
## [0.0.2]
31+
## [0.0.2] - 07-01-2025
2132
- 🐞 Added fix for python 3.9, by refactoring incompatible type annotation
2233
- Loosened the version requirements for pytest (until the lower bound have been discovered, with automated testing)
2334
- Improved metadata for pypi
2435

25-
## [0.0.1]
36+
## [0.0.1] - 06-01-2025
2637
- Initial release of Snappylapy
2738
- Implemented basic snapshot testing functionality for dict, list, bytes and str data types

README.md

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Welcome to **Snappylapy**, a powerful and intuitive snapshot testing tool for Python's pytest framework. Snappylapy simplifies the process of capturing and verifying snapshots of your data, ensuring your code behaves as expected across different runs. With Snappylapy, you can save snapshots in a human-readable format and deserialize them for robust integration testing, providing a clear separation layer to help isolate errors and maintain code integrity.
44

55
## Installation
6-
To install Snappylapy, use the following command:
6+
To get started with Snappylapy, install the package via pip:
77

88
```bash
99
pip install snappylapy
@@ -49,22 +49,6 @@ def test_snapshot_dict(expect: Expect):
4949
expect.dict(data).to_match_snapshot()
5050
```
5151

52-
Allows users full control to select output location for snapshots so they can be stored together with testcases.
53-
54-
```python
55-
import pytest
56-
import pathlib
57-
from snappylapy import Expect
58-
from mypackage import my_function
59-
60-
@pytest.mark.parametrize('case_dir', list(pathlib.Path('test_cases').iterdir()))
61-
def test_my_function(case_dir: pathlib.Path, expect: Expect):
62-
expect.snapshot_dir = case_dir / "__snapshots__"
63-
expect.test_results_dir = case_dir / "__test_results__"
64-
result = my_function(case_dir)
65-
expect.dict(result).to_match_snapshot()
66-
```
67-
6852
In this example, `snappylapy` captures the output of `my_function` and compares it against a stored snapshot. If the output changes unexpectedly, pytest will flag the test, allowing you to review the differences and ensure your code behaves as expected.
6953

7054
Snappylapy can use the snapshots created for inputs in another test. You can think of it as automated/easier mock data generation and management.
@@ -88,16 +72,6 @@ def test_load_snapshot_from_file(load_snapshot: LoadSnapshot):
8872

8973
This can be great for external dependencies, for example an AI service, that might change response over time. With this approach we can isolate the changes to the service and still make succeding tests pass.
9074

91-
## Getting Started
92-
93-
To get started with Snappylapy, install the package via pip:
94-
95-
```bash
96-
pip install snappylapy
97-
```
98-
99-
Add Snappylapy to your pytest configuration and start writing tests that capture and verify snapshots effortlessly.
100-
10175
## The output structure
10276

10377
The results is split into two folders, for ease of comparison, and for handling stochastic/variable outputs (timestamps, generated ids, llm outputs, third party api responses etc).
@@ -112,12 +86,6 @@ Update snapshots with:
11286
pytest --snapshot-update
11387
```
11488

115-
A diff report in html can be generated with (not implemented yet ❌):
116-
117-
```bash
118-
pytest --snappylapy-html=report.html
119-
```
120-
12189
## Fixtures and roadmap
12290
Registers fixtures:
12391
- expect ✅

scripts/extract_examples_from_markdown.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,9 @@ def save_codeblocks(code_blocks: list[str], save_dir: pathlib.Path) -> None:
3636
file.write(block)
3737

3838
code_blocks = extract_codeblocks(PATH)
39+
40+
# Delete everything in the save directory
41+
for file in PATH_SAVE_DIR.iterdir():
42+
file.unlink()
43+
3944
save_codeblocks(code_blocks, PATH_SAVE_DIR)

todo.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ Markdown Checkbox VSCode Extension
22
- ctl+shift+enter to toggle checkbox
33

44
# Todo
5+
- [ ] Update README.md with example of how to use the parametization functionality
56
- [ ] Do a significant boost in testing both manually and adding automated tests
67
- [ ] Update README.md such that todo items is shown here instead of in the README.md
7-
- [ ] Change setting of path to only have a single path, and make the __snapshots__ and __test_results__ name fixed
8-
- [ ] Make the folder names of __snapshots__ and __test_results__ enforced to be fixed (needed for cleanup and diffing)
98
- [ ] Add removal command of ophaned snapshots to snappylapy cli
109

1110

1211
# Backlog
12+
- [ ] A diff report in html can be generated with `pytest --snappylapy-html=report.html`
1313

1414
# Done
15+
- [X] ~~*Add snappylapy parametization functionality to snappylapy and allow it to be loaded in the load_snapshot fixture*~~ [2025-01-19]
16+
- [X] ~~*Make the folder names of __snapshots__ and __test_results__ enforced to be fixed (needed for cleanup and diffing)*~~ [2025-01-19]
17+
- [X] ~~*Change setting of path to only have a single path configurable and update such it is configured through the marker*~~ [2025-01-19]
1518
- [X] ~~*Do reporting showing count of updated, created and deleted snapshots*~~ [2025-01-18]
1619
- [X] ~~*Rename output file names of snapshots to match [filename][testname][name].extention conversion*~~ [2025-01-15]

0 commit comments

Comments
 (0)