Skip to content

Commit 6bd16f3

Browse files
authored
Final cleanup before publish (#502)
2 parents 51fefff + 54a4b7a commit 6bd16f3

File tree

12 files changed

+42
-39
lines changed

12 files changed

+42
-39
lines changed

Diff for: CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Contributing to Selfie
22

33
- To improve our webpage go to [`selfie.dev/README.md`](selfie.dev/README.md)
4+
- To improve our Python, go to [`python/README.md`](python/README.md)
45
- To improve our JVM, Javascript, or WASM implementations, go to [`jvm/README.md`](jvm/README.md)
56
- To improve the webpage of our published kdoc, [kdoc.selfie.dev](https://kdoc.selfie.dev), go to [`jvm/gradle/dokka/README.md`](jvm/gradle/dokka/README.md)
67
- To contribute for a different platform (python, go, etc.) we're happy to help! It should probably live in a different repo until it's close to `1.0`, but once it's near completion we're happy to maintain it here if you would like. Discuss in [selfie#85](https://github.com/diffplug/selfie/issues/85), but also feel free to open a PR with any ideas you have.

Diff for: README.md

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
# Selfie: snapshot testing and [memoizing](https://selfie.dev/jvm/cache) for Java, Kotlin, and the JVM
1+
# Selfie: snapshot testing and memoizing for Python, JVM, and [(your PR here)](https://github.com/diffplug/selfie/issues/85)
22

33
![gif demo of selfie in action](https://docs.diffplug.com/selfie/selfie-demo.gif)
44

55
## Key features
66

7-
- Just [add a test dependency](https://selfie.dev/jvm/get-started#installation), zero setup, zero config.
8-
- Snapshots can be [inline literals](https://selfie.dev/jvm#literal) or [on disk](https://selfie.dev/jvm#like-a-filesystem).
9-
- Use `expectSelfie` for testing or `cacheSelfie` for [memoizing expensive API calls](https://selfie.dev/jvm/cache).
7+
- Just add a test dependency ([py](https://selfie.dev/py/get-started#installation), [jvm](https://selfie.dev/jvm/get-started#installation)), zero setup, zero config.
8+
- Snapshots can be [inline literals](https://selfie.dev/py#literal) or [on disk](https://selfie.dev/py#like-a-filesystem).
9+
- Use `expect_selfie` for testing or `cache_selfie` for [memoizing expensive API calls](https://selfie.dev/py/cache).
1010
- Disk snapshots are automatically [garbage collected](https://github.com/diffplug/selfie/blob/main/jvm/selfie-runner-junit5/src/main/kotlin/com/diffplug/selfie/junit5/SelfieGC.kt) when the test class or test method is removed.
11-
- Snapshots are **just strings**. Use html, json, markdown, whatever. No [magic serializers](https://selfie.dev/jvm/facets#typed-snapshots).
11+
- Snapshots are **just strings**. Use html, json, markdown, whatever. No [magic serializers](https://selfie.dev/py/cache#roundtripping-typed-data).
1212
- Record **multiple facets** of the entity under test, e.g. for a web request...
1313
- store the HTML as one facet
1414
- store HTML-rendered-to-markdown as another facet
1515
- store cookies in another facet
1616
- **assert some facets on disk, others inline**
17-
- see gif above for live demo, detailed example [here](https://selfie.dev/jvm/advanced)
17+
- see gif above for live demo, detailed example [here](https://selfie.dev/py/facets#harmonizing-disk-and-inline-literals)
1818

19-
JVM only for now, [python](https://github.com/diffplug/selfie/issues/170) is in progress, other platforms on the way: [js](https://github.com/diffplug/selfie/issues/84), [.NET, go, ...](https://github.com/diffplug/selfie/issues/85)
19+
Python and JVM ports are both production-ready, other platforms on the way: [js](https://github.com/diffplug/selfie/issues/84), [.NET, go, ...](https://github.com/diffplug/selfie/issues/85)
2020

2121
## Documentation
2222

23-
- [Installation](https://selfie.dev/jvm/get-started#installation)
24-
- [Quickstart](https://selfie.dev/jvm/get-started#quickstart)
25-
- [Facets](https://selfie.dev/jvm/facets)
26-
- [Caching / memoizing](https://selfie.dev/jvm/cache)
27-
- [Why selfie](https://selfie.dev/jvm)
28-
- [API reference](https://kdoc.selfie.dev/)
23+
- Quickstart **([py](https://selfie.dev/py/get-started#quickstart), [jvm](https://selfie.dev/jvm/get-started#quickstart))**
24+
- Facets **([py](https://selfie.dev/py/facets), [jvm](https://selfie.dev/jvm/facets))**
25+
- Caching / memoizing **([py](https://selfie.dev/py/cache), [jvm](https://selfie.dev/jvm/cache))**
26+
- Why selfie **([py](https://selfie.dev/py), [jvm](https://selfie.dev/jvm))**
27+
- API reference **([py](https://pydoc.selfie.dev/namespacemembers_func), [jvm](https://kdoc.selfie.dev/))**
2928

3029
## Contributing
3130

Diff for: jvm/README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# Selfie snapshot testing for Java, Kotlin, and the JVM
22

3-
- [Quickstart](https://selfie.dev/jvm/get-started)
4-
- [Facets](https://selfie.dev/jvm/facets)
5-
- [Caching / memoizing](https://selfie.dev/jvm/cache)
6-
- [Why selfie](https://selfie.dev/jvm)
3+
- High-level documentation - [selfie.dev](https://selfie.dev/jvm/get-started).
4+
- API documentation - [pydoc.selfie.dev](https://kdoc.selfie.dev).
5+
- Source code - [github.com/diffplug/selfie](https://github.com/diffplug/selfie)
76

87
## Contributing
98

Diff for: python/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
# Selfie snapshot testing for Python
2+
13
- High-level documentation - [selfie.dev](https://selfie.dev/py/get-started).
24
- API documentation - [pydoc.selfie.dev](https://pydoc.selfie.dev/namespaces).
35
- Source code - [github.com/diffplug/selfie](https://github.com/diffplug/selfie)
46

57
## Contributing
68

7-
Dependencies are managed using uv:
9+
PR's welcome! Dependencies are managed using uv:
810

911
- https://docs.astral.sh/uv/getting-started/installation/
1012
- then cd into `selfie-lib` and run `uv sync` to get the dependencies

Diff for: python/example-pytest-selfie/tests/binary_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_binary_file_duplicate_unequal():
4141
"tests/binary_test__test_binary_file_duplicate_unequal.bin"
4242
)
4343
expect_selfie(safify(str(exc_info.value))).to_be(
44-
"Snapshot mismatch, TODO: string comparison"
44+
"Snapshot mismatch (error msg could be better https://github.com/diffplug/selfie/issues/501)"
4545
)
4646

4747

@@ -65,7 +65,7 @@ def test_base64_mismatch():
6565
with pytest.raises(Exception) as exc_info:
6666
expect_selfie(b"test data").to_be_base64("AAAA")
6767
expect_selfie(safify(str(exc_info.value))).to_be(
68-
"Snapshot mismatch, TODO: string comparison"
68+
"Snapshot mismatch (error msg could be better https://github.com/diffplug/selfie/issues/501)"
6969
)
7070

7171

Diff for: python/selfie-lib/selfie_lib/SnapshotSystem.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ def msg_snapshot_not_found_no_such_file(self, file) -> str:
125125
return self.msg(f"Snapshot not found: no such file {file}")
126126

127127
def msg_snapshot_mismatch(self, expected: str, actual: str) -> str: # noqa: ARG002
128-
return self.msg("Snapshot mismatch, TODO: string comparison")
128+
return self.msg(
129+
"Snapshot mismatch (error msg could be better https://github.com/diffplug/selfie/issues/501)"
130+
)
129131

130132
def msg_snapshot_mismatch_binary(self, expected: bytes, actual: bytes) -> str:
131133
return self.msg_snapshot_mismatch(

Diff for: selfie.dev/public/_redirects

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/jvm/advanced /jvm/facets 301
22
/js https://github.com/diffplug/selfie/issues/84
33
/js/* https://github.com/diffplug/selfie/issues/84
4-
/py https://github.com/diffplug/selfie/issues/85
54
/go https://github.com/diffplug/selfie/issues/85
65
/go/* https://github.com/diffplug/selfie/issues/85
76
/other-platforms https://github.com/diffplug/selfie/issues/85
8-
/other-platforms/* https://github.com/diffplug/selfie/issues/85
9-
/cs490 https://docs.google.com/presentation/d/1K_xOISzzx0NRnNi_p7GrLIFVh5u9s0mstq2m3Idq19Q/edit?usp=sharing
7+
/other-platforms/* https://github.com/diffplug/selfie/issues/85

Diff for: selfie.dev/src/components/ButtonList.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ export function ButtonList() {
1919
"desktop:w-[490px]"
2020
)}
2121
>
22-
<Link href="/jvm">
22+
<Link href="/py">
2323
<Button
2424
className={
25-
["jvm", ""].includes(selectedLanguage)
26-
? pressedClasses
27-
: unPressedClasses
25+
selectedLanguage === "py" ? pressedClasses : unPressedClasses
2826
}
2927
>
30-
jvm
28+
py
3129
</Button>
3230
</Link>
33-
<Link href="/py">
31+
<Link href="/jvm">
3432
<Button
3533
className={
36-
selectedLanguage === "py" ? pressedClasses : unPressedClasses
34+
["jvm", ""].includes(selectedLanguage)
35+
? pressedClasses
36+
: unPressedClasses
3737
}
3838
>
39-
py
39+
jvm
4040
</Button>
4141
</Link>
4242
<Link href="/js">

Diff for: selfie.dev/src/components/HeroDemoGif.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ export function ButtonList() {
7373
"desktop:w-[490px]"
7474
)}
7575
>
76+
<Link href="/py">
77+
<Button className={unPressedClasses}>py</Button>
78+
</Link>{" "}
7679
<Link href="/jvm">
7780
<Button className={unPressedClasses}>jvm</Button>
7881
</Link>{" "}
7982
<Link href="/js">
8083
<Button className={unPressedClasses}>js</Button>
8184
</Link>{" "}
82-
<Link href="/other-platforms">
83-
<Button className={unPressedClasses}>py</Button>
84-
</Link>{" "}
8585
<Link href="/other-platforms">
8686
<Button className={unPressedClasses}>...</Button>
8787
</Link>

Diff for: selfie.dev/src/pages/jvm/get-started.mdx

+3-2
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ expectSelfie(TimeUnit.DAYS.toMillis(365*1_000_000L)).toBe(31_536_000_000_000_000
183183
expectSelfie(new byte[100]).toMatchDisk();
184184
```
185185

186-
But the real power of selfie is asserting on arbitrary objects using **facets**, which are covered in the [advanced section](/jvm/facets).
186+
But the real power of selfie is asserting on arbitrary objects using **facets**, which are covered in the [facets section](/jvm/facets).
187187

188188
## Reference
189189

@@ -203,6 +203,7 @@ Full API documentation is available at [kdoc.selfie.dev](https://kdoc.selfie.dev
203203
- `interactive`, default
204204
- `readonly`, default if `CI` environment variable is `true`
205205
- `overwrite`, all snapshots can be overwritten
206-
- `Camera` and `Lens` are covered in the [advanced section](/jvm/facets).
206+
- `Camera` and `Lens` are covered in the [facet section](/jvm/facets)
207+
- `cacheSelfie` and binary snapshots (`toBeBase64` and `toBeFile`) are covered in the [cache section](/jvm/cache)
207208

208209
*Pull requests to improve the landing page and documentation are greatly appreciated, you can find the [source code here](https://github.com/diffplug/selfie).*

Diff for: selfie.dev/src/pages/py/cache.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const imageUrl = "https://selfie.dev/cache.webp";
77

88
<DocsImage imgAbsoluteUrl={imageUrl} />
99

10-
*`cacheSelfie` helps you build fast deterministic tests even if they contain slow non-deterministic components. A generative AI example is available [here](https://github.com/diffplug/selfie/blob/main/python/example-pytest-selfie/tests/cache_selfie_test.py).*
10+
*`cache_selfie` helps you build fast deterministic tests even if they contain slow non-deterministic components. A generative AI example is available [here](https://github.com/diffplug/selfie/blob/main/python/example-pytest-selfie/tests/cache_test.py).*
1111

1212
To use `expect_selfie`, you pass a _value_ that you want to snapshot.
1313

@@ -46,7 +46,7 @@ You have these choices for specifying the data in a snapshot:
4646

4747
```python
4848
cache_selfie(lambda: "string").to_be("string")
49-
cache_selfie(lambda:"string").to_match_disk()
49+
cache_selfie(lambda: "string").to_match_disk()
5050
cache_selfie_binary(lambda: bytearray[3]).to_be_base64("AAAA")
5151
cache_selfie_binary(lambda: bytearray[3]).to_be_file("pkg/someFile.ext")
5252
cache_selfie_binary(lambda: bytearray[3]).to_match_disk()

Diff for: selfie.dev/src/pages/py/get-started.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,6 @@ Full API documentation is available at [pydoc.selfie.dev](https://pydoc.selfie.d
136136
- `readonly`, default if `CI` environment variable is `true`
137137
- `overwrite`, all snapshots can be overwritten
138138
- `Camera` and `Lens` are covered in the [facets section](/py/facets).
139+
- `cache_selfie` and binary snapshots (`to_be_base64` and `to_be_file`) are covered in the [cache section](/py/cache)
139140

140141
_Pull requests to improve the landing page and documentation are greatly appreciated, you can find the [source code here](https://github.com/diffplug/selfie)._

0 commit comments

Comments
 (0)