Skip to content

Commit 9a7a8e4

Browse files
isidorejmasonleegregorrieglerblade290nitsanavni
committed
- r semi inline uses lambda
Co-Authored-By: jmasonlee <262853+jmasonlee@users.noreply.github.com> Co-Authored-By: Gregor Riegler <rieglerg85@gmail.com> Co-Authored-By: blade290 <43077216+blade290@users.noreply.github.com> Co-Authored-By: Nitsan Avni <nitsanav@gmail.com> Co-Authored-By: bhargavgundu <7643639+bhargavgundu@users.noreply.github.com>
1 parent 8704465 commit 9a7a8e4

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

approvaltests/inline/inline_options.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SemiAutomaticInlineOptions(InlineOptions):
2828
def apply(self, options: "Options") -> "Options":
2929
return options.with_reporter(
3030
InlinePythonReporter(
31-
ReporterThatAutomaticallyApproves(), add_approval_line=True
31+
ReporterThatAutomaticallyApproves(), add_approval_line=False, previous_result=lambda __: DELETE_ME_TO_APPROVE_
3232
)
3333
)
3434

@@ -61,18 +61,18 @@ def previous_capture():
6161
from approvaltests.namer.inline_python_reporter import InlinePythonReporter
6262
from approvaltests.reporters import ReporterThatAutomaticallyApproves
6363

64-
def applesauce(approved_path):
64+
def create_previous_capture_suffix(approved_path):
6565
approved_text = Path(approved_path).read_text()
6666
approved_text = approved_text.rsplit("\n", 1)[0]
6767
approved_text = approved_text.rsplit(PREVIOUS_RESULT_, 1)[-1]
6868
previous_result_stuff = lambda: "\n" + PREVIOUS_RESULT_ + approved_text
6969
return DELETE_ME_TO_APPROVE_ + previous_result_stuff()
70-
class SemiAutomaticInlineOptions(InlineOptions):
70+
class PreviousCaptureInlineOptions(InlineOptions):
7171
def apply(self, options: "Options") -> "Options":
7272
return options.with_reporter(
7373
InlinePythonReporter(
74-
ReporterThatAutomaticallyApproves(), add_approval_line=False, previous_result=applesauce
74+
ReporterThatAutomaticallyApproves(), add_approval_line=False, previous_result=create_previous_capture_suffix
7575
)
7676
)
7777

78-
return SemiAutomaticInlineOptions()
78+
return PreviousCaptureInlineOptions()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
42
2+
***** DELETE ME TO APPROVE *****

tests/test_inline_approvals.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,15 @@ def test_inline_with_preserved_approved_text():
202202
except ApprovalException:
203203
pass
204204
verify(get_approved_via_doc_string())
205+
206+
def test_inline_with_semi_automatic_inline():
207+
"""
208+
42
209+
***** DELETE ME TO APPROVE *****
210+
"""
211+
options = Options().inline(InlineOptions.semi_automatic())
212+
try:
213+
verify("42", options=options)
214+
except ApprovalException:
215+
pass
216+
verify(get_approved_via_doc_string())

0 commit comments

Comments
 (0)