Skip to content

Commit 7ec8e97

Browse files
committed
. d format and update markdown snippets
1 parent d1e435e commit 7ec8e97

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

approvaltests/scrubbers/date_scrubber.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import textwrap
2-
from approval_utilities.utilities.multiline_string_utils import remove_indentation_from
32
from typing import List, Tuple
43

4+
from approval_utilities.utilities.multiline_string_utils import remove_indentation_from
55
from approvaltests.scrubbers import create_regex_scrubber
66
from approvaltests.scrubbers.scrubbers import Scrubber
77

@@ -19,14 +19,16 @@ def add_scrubber(example: str, regex: str, *, display_message: bool = True) -> N
1919
except re.error as e:
2020
raise Exception(f"Invalid regex pattern '{regex}': {e}")
2121
_custom_scrubbers.append((regex, [example]))
22-
22+
2323
if display_message:
24-
message = remove_indentation_from(f"""
24+
message = remove_indentation_from(
25+
f"""
2526
You are using a custom date scrubber. If you think the format you want to scrub would be useful for others, please add it to https://github.com/approvals/ApprovalTests.Python/issues/124.
2627
2728
To suppress this message, use
2829
DateScrubber.add_scrubber("{example}", "{regex}", display_message=False)
29-
""")
30+
"""
31+
)
3032
print(message)
3133

3234
@staticmethod

docs/how_to/scrub_dates.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ verify(
1919
options=Options().with_scrubber(DateScrubber.get_scrubber_for("00:00:00")),
2020
)
2121
```
22-
<sup><a href='/tests/scrubbers/test_date_scrubber.py#L23-L28' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrub-date-example' title='Start of snippet'>anchor</a></sup>
22+
<sup><a href='/tests/scrubbers/test_date_scrubber.py#L25-L30' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrub-date-example' title='Start of snippet'>anchor</a></sup>
2323
<!-- endSnippet -->
2424

2525
which will produce
@@ -42,15 +42,15 @@ If you encounter a date format that isn't supported by the built-in formats, you
4242
from approvaltests.scrubbers.date_scrubber import DateScrubber
4343

4444
# Add a custom date format
45-
DateScrubber.add_scrubber("2025-07-20", r"\d{4}-\d{2}-\d{2}")
45+
DateScrubber.add_scrubber("2025-07-20", r"\d{4}-\d{2}-\d{2}", display_message=False)
4646

4747
# Now you can use it in your tests
4848
verify(
4949
"Event scheduled for 2025-07-20",
5050
options=Options().with_scrubber(DateScrubber.get_scrubber_for("2025-07-20")),
5151
)
5252
```
53-
<sup><a href='/tests/scrubbers/test_date_scrubber.py#L77-L88' title='Snippet source file'>snippet source</a> | <a href='#snippet-custom_date_format_example' title='Start of snippet'>anchor</a></sup>
53+
<sup><a href='/tests/scrubbers/test_date_scrubber.py#L79-L90' title='Snippet source file'>snippet source</a> | <a href='#snippet-custom_date_format_example' title='Start of snippet'>anchor</a></sup>
5454
<!-- endSnippet -->
5555
**Global scope**: Custom scrubbers are available globally once added
5656

tests/scrubbers/test_date_scrubber.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_supported_formats_as_table() -> None:
103103
def test_custom_scrubber_displays_message(capsys: CaptureFixture[str]) -> None:
104104
"""
105105
You are using a custom date scrubber. If you think the format you want to scrub would be useful for others, please add it to https://github.com/approvals/ApprovalTests.Python/issues/124.
106-
106+
107107
To suppress this message, use
108108
DateScrubber.add_scrubber("2023-Dec-25", "\d{4}-[A-Za-z]{3}-\d{2}", display_message=False)
109109
@@ -117,11 +117,11 @@ def test_custom_scrubber_displays_message(capsys: CaptureFixture[str]) -> None:
117117

118118

119119
def test_custom_scrubber_message_can_be_suppressed(capsys: CaptureFixture[str]) -> None:
120-
"""
121-
122-
"""
120+
""" """
123121
try:
124-
DateScrubber.add_scrubber("2023-Dec-25", r"\d{4}-[A-Za-z]{3}-\d{2}", display_message=False)
122+
DateScrubber.add_scrubber(
123+
"2023-Dec-25", r"\d{4}-[A-Za-z]{3}-\d{2}", display_message=False
124+
)
125125
captured = capsys.readouterr()
126126
verify(captured.out, options=Options().inline())
127127
finally:

0 commit comments

Comments
 (0)