From 6c3259ae66f801af76e69c9b727c2803bfba33f0 Mon Sep 17 00:00:00 2001 From: github actions Date: Sun, 7 Apr 2024 18:40:11 +0000 Subject: [PATCH] d updated markdown snippets --- .../inline_approvals_with_parse_input.md | 36 ++++++++++++++++--- tests/test_parse_inputs.py | 5 ++- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/docs/how_to/inline_approvals_with_parse_input.md b/docs/how_to/inline_approvals_with_parse_input.md index 5d9750b..9f8c327 100644 --- a/docs/how_to/inline_approvals_with_parse_input.md +++ b/docs/how_to/inline_approvals_with_parse_input.md @@ -1,6 +1,18 @@ # How to have tight feedback loops with inline approvals and parse_input -toc + +## Contents + + * [Problem](#problem) + * [Solution](#solution) + * [Handling 1 Parameter](#handling-1-parameter) + * [Scenario - Counting Vowels](#scenario---counting-vowels) + * [Step 1: Write the Test](#step-1-write-the-test) + * [Step 2: Run the Test](#step-2-run-the-test) + * [Step 3: Implement and rerun](#step-3-implement-and-rerun) + * [Step 4: Commit](#step-4-commit) + * [Handling 1 Parameter that is not a string](#handling-1-parameter-that-is-not-a-string) + * [Handling 2 Parameters](#handling-2-parameters) ## Problem You are doing TDD on a pure function that takes some parameters and returns a result. @@ -54,7 +66,23 @@ Kody -> 0 Everytime you run the tests, you automatically see the result at the top in the docstring. As you want more test cases just add more lines to the docstring. Here's an exmaple of where we have handled O, E, & A. -snippet: parse_input_step_3 + + +```py +def count_vowels(s: str) -> int: + return sum(1 for c in s if c in "aeo") + +def test_count_vowels(): + """ + Kody -> 1 + Teresa -> 3 + Green -> 2 + """ + parse = Parse.doc_string(auto_approve=True) + parse.verify_all(count_vowels) +``` +snippet source | anchor + ### Step 4: Commit @@ -77,7 +105,7 @@ def test_with_transformation(): parse = Parse.doc_string(auto_approve=True) parse.transform(int).verify_all(bin) ``` -snippet source | anchor +snippet source | anchor ## Handling 2 Parameters @@ -95,5 +123,5 @@ def test_with_two_parameters(): parse = Parse.doc_string(auto_approve=True) parse.transform2(str, int).verify_all(lambda s, i: s * i) ``` -snippet source | anchor +snippet source | anchor diff --git a/tests/test_parse_inputs.py b/tests/test_parse_inputs.py index 09306fd..6bfefc0 100644 --- a/tests/test_parse_inputs.py +++ b/tests/test_parse_inputs.py @@ -65,15 +65,18 @@ def test_count_vowels(): # end-snippet test_count_vowels() + + def test_example_step_2(): """ Kody -> 1 Teresa -> 3 Green -> 2 """ + # begin-snippet: parse_input_step_3 def count_vowels(s: str) -> int: - return sum(1 for c in s if c in "aeo") + return sum(1 for c in s if c in "aeo") def test_count_vowels(): """