Skip to content

Commit a63a195

Browse files
committed
. d format and update markdown snippets
1 parent 02b5cb2 commit a63a195

11 files changed

Lines changed: 25 additions & 12 deletions

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class TestSelectReporterFromClass(unittest.TestCase):
171171
def test_simple(self):
172172
verify("Hello", options=Options().with_reporter(report_with_beyond_compare()))
173173
```
174-
<sup><a href='/tests/samples/test_getting_started.py#L25-L31' title='Snippet source file'>snippet source</a> | <a href='#snippet-select_reporter_from_class' title='Start of snippet'>anchor</a></sup>
174+
<sup><a href='/tests/samples/test_getting_started.py#L27-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-select_reporter_from_class' title='Start of snippet'>anchor</a></sup>
175175
<!-- endSnippet -->
176176

177177
You can also use the `GenericDiffReporterFactory` to find and select the first diff utility that exists on our system.
@@ -182,6 +182,7 @@ An advantage of this method is you can modify the reporters.json file directly t
182182
<a id='snippet-select_reporter_from_factory'></a>
183183
```py
184184
class TestSelectReporter(unittest.TestCase):
185+
@override
185186
def setUp(self):
186187
self.factory = GenericDiffReporterFactory()
187188

@@ -190,7 +191,7 @@ class TestSelectReporter(unittest.TestCase):
190191
"Hello", options=Options().with_reporter(self.factory.get("BeyondCompare"))
191192
)
192193
```
193-
<sup><a href='/tests/samples/test_getting_started.py#L11-L22' title='Snippet source file'>snippet source</a> | <a href='#snippet-select_reporter_from_factory' title='Start of snippet'>anchor</a></sup>
194+
<sup><a href='/tests/samples/test_getting_started.py#L12-L24' title='Snippet source file'>snippet source</a> | <a href='#snippet-select_reporter_from_factory' title='Start of snippet'>anchor</a></sup>
194195
<!-- endSnippet -->
195196

196197
Or you can build your own GenericDiffReporter on the fly
@@ -207,7 +208,7 @@ class GettingStartedTest(unittest.TestCase):
207208
),
208209
)
209210
```
210-
<sup><a href='/tests/samples/test_getting_started.py#L34-L45' title='Snippet source file'>snippet source</a> | <a href='#snippet-custom_generic_diff_reporter' title='Start of snippet'>anchor</a></sup>
211+
<sup><a href='/tests/samples/test_getting_started.py#L36-L47' title='Snippet source file'>snippet source</a> | <a href='#snippet-custom_generic_diff_reporter' title='Start of snippet'>anchor</a></sup>
211212
<!-- endSnippet -->
212213

213214
As long as `C:/my/favorite/diff/utility.exe` can be invoked from the command line using the format `utility.exe file1 file2`

approval_utilities/utilities/string_wrapper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from typing_extensions import override
2+
3+
24
class StringWrapper:
35
def __init__(self) -> None:
46
self.string = ""

approvaltests/approval_exception.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from typing_extensions import override
2+
3+
24
class ApprovalException(Exception):
35
def __init__(self, value: str) -> None:
46
super().__init__(self)

approvaltests/reporter_missing_exception.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from typing_extensions import override
2+
3+
24
class ReporterMissingException(BaseException):
35
def __init__(self, key: str) -> None:
46
super().__init__(self)

approvaltests/reporters/python_native_reporter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing_extensions import override
2+
23
#!/usr/bin/env python
34

45
import os

docs/how_to/create_a_custom_reporter.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def load_ndarray(path):
1616
return np.load(f)
1717

1818
class NDArrayDiffReporter(Reporter):
19+
@override
1920
def report(self, received_path: str, approved_path: str) -> bool:
2021
if not Path(approved_path).is_file():
2122
self._create_empty_array(approved_path)
@@ -27,5 +28,5 @@ class NDArrayDiffReporter(Reporter):
2728
print(np.testing.build_err_msg([received, approved], err_msg=to_approve_msg))
2829
return True
2930
```
30-
<sup><a href='/tests/test_example_numpy.py#L31-L51' title='Snippet source file'>snippet source</a> | <a href='#snippet-numpy_custom_reporter' title='Start of snippet'>anchor</a></sup>
31+
<sup><a href='/tests/test_example_numpy.py#L32-L53' title='Snippet source file'>snippet source</a> | <a href='#snippet-numpy_custom_reporter' title='Start of snippet'>anchor</a></sup>
3132
<!-- endSnippet -->

docs/how_to/create_custom_verify_methods.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def test_verifiable(self):
5858
self.title = title
5959
self.text = text
6060

61+
@override
6162
def __str__(self) -> str:
6263
return remove_indentation_from(
6364
f"""
@@ -66,13 +67,14 @@ def test_verifiable(self):
6667
"""
6768
)
6869

70+
@override
6971
def get_verify_parameters(self, options: Options) -> VerifyParameters:
7072
return VerifyParameters(options.for_file.with_extension(".md"))
7173

7274
verify(
7375
MarkdownParagraph("Paragraph Title", "This is where the paragraph text is.")
7476
)
7577
```
76-
<sup><a href='/tests/test_verify.py#L304-L326' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifiable_object_example' title='Start of snippet'>anchor</a></sup>
78+
<sup><a href='/tests/test_verify.py#L310-L334' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifiable_object_example' title='Start of snippet'>anchor</a></sup>
7779
<!-- endSnippet -->
7880

docs/how_to/test_combinations_of_inputs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ If you wanted to test this matrix combination approvals can do it with a single
3232
```py
3333
verify_all_combinations(is_awake, [["Monday", "Sunday"], ["7:00", "9:00", "11:00"]])
3434
```
35-
<sup><a href='/tests/test_combinations.py#L149-L151' title='Snippet source file'>snippet source</a> | <a href='#snippet-combination_introduction' title='Start of snippet'>anchor</a></sup>
35+
<sup><a href='/tests/test_combinations.py#L152-L154' title='Snippet source file'>snippet source</a> | <a href='#snippet-combination_introduction' title='Start of snippet'>anchor</a></sup>
3636
<!-- endSnippet -->
3737

3838
## When to use Combinations
@@ -52,7 +52,7 @@ inputs1 = ["input1.value1", "input1.value2"]
5252
inputs2 = ["input2.value1", "input2.value2", "input2.value3"]
5353
verify_all_combinations(lambda a, b: "placeholder", [inputs1, inputs2])
5454
```
55-
<sup><a href='/tests/test_combinations.py#L155-L159' title='Snippet source file'>snippet source</a> | <a href='#snippet-combinations_starting_point' title='Start of snippet'>anchor</a></sup>
55+
<sup><a href='/tests/test_combinations.py#L158-L162' title='Snippet source file'>snippet source</a> | <a href='#snippet-combinations_starting_point' title='Start of snippet'>anchor</a></sup>
5656
<!-- endSnippet -->
5757

5858
2. Modify each input container for your chosen values.
@@ -92,7 +92,7 @@ verify_all_combinations_with_labeled_input(
9292
arg2=(2, 4),
9393
)
9494
```
95-
<sup><a href='/tests/test_combinations.py#L126-L132' title='Snippet source file'>snippet source</a> | <a href='#snippet-named_combinations' title='Start of snippet'>anchor</a></sup>
95+
<sup><a href='/tests/test_combinations.py#L128-L134' title='Snippet source file'>snippet source</a> | <a href='#snippet-named_combinations' title='Start of snippet'>anchor</a></sup>
9696
<!-- endSnippet -->
9797

9898
which will produce the following output:

docs/how_to/verify-binary.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ filename = get_adjacent_file(name)
2424
with open(filename, mode="rb") as f:
2525
verify_binary(f.read(), ".png")
2626
```
27-
<sup><a href='/tests/test_verify.py#L179-L184' title='Snippet source file'>snippet source</a> | <a href='#snippet-verify_binary_image' title='Start of snippet'>anchor</a></sup>
27+
<sup><a href='/tests/test_verify.py#L183-L188' title='Snippet source file'>snippet source</a> | <a href='#snippet-verify_binary_image' title='Start of snippet'>anchor</a></sup>
2828
<!-- endSnippet -->
2929

3030
Which will produce
@@ -47,7 +47,7 @@ def test_simulator_produces_correct_output():
4747
options=Options().with_reporter(NDArrayDiffReporter()),
4848
)
4949
```
50-
<sup><a href='/tests/test_example_numpy.py#L16-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-verify_numpy_array' title='Start of snippet'>anchor</a></sup>
50+
<sup><a href='/tests/test_example_numpy.py#L17-L27' title='Snippet source file'>snippet source</a> | <a href='#snippet-verify_numpy_array' title='Start of snippet'>anchor</a></sup>
5151
<!-- endSnippet -->
5252

5353
It also shows the use of a custom reporter, which uses the NumPy testing features to produce a well-formatted error report highlighting the differences between arrays.
@@ -60,6 +60,7 @@ def load_ndarray(path):
6060
return np.load(f)
6161

6262
class NDArrayDiffReporter(Reporter):
63+
@override
6364
def report(self, received_path: str, approved_path: str) -> bool:
6465
if not Path(approved_path).is_file():
6566
self._create_empty_array(approved_path)
@@ -71,5 +72,5 @@ class NDArrayDiffReporter(Reporter):
7172
print(np.testing.build_err_msg([received, approved], err_msg=to_approve_msg))
7273
return True
7374
```
74-
<sup><a href='/tests/test_example_numpy.py#L31-L51' title='Snippet source file'>snippet source</a> | <a href='#snippet-numpy_custom_reporter' title='Start of snippet'>anchor</a></sup>
75+
<sup><a href='/tests/test_example_numpy.py#L32-L53' title='Snippet source file'>snippet source</a> | <a href='#snippet-numpy_custom_reporter' title='Start of snippet'>anchor</a></sup>
7576
<!-- endSnippet -->

docs/reference/storyboard.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ascii_wheel.advance()
2929
story.add_frame(ascii_wheel)
3030
verify(story)
3131
```
32-
<sup><a href='/tests/test_verify.py#L228-L235' title='Snippet source file'>snippet source</a> | <a href='#snippet-use_storyboard' title='Start of snippet'>anchor</a></sup>
32+
<sup><a href='/tests/test_verify.py#L233-L240' title='Snippet source file'>snippet source</a> | <a href='#snippet-use_storyboard' title='Start of snippet'>anchor</a></sup>
3333
<!-- endSnippet -->
3434

3535
will produce

0 commit comments

Comments
 (0)