Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
twelve-days: add test template (#1883)
- add header, footer generator macros
- Loading branch information
1 parent
e1e72d7
commit ac58169
Showing
4 changed files
with
198 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{%- import "generator_macros.j2" as macros -%} | ||
{{ macros.header(exercise, properties, version) }} | ||
|
||
class {{ exercise | camel_case }}Test(unittest.TestCase): | ||
{# All test cases in this exercise are nested, so use two for loops -#} | ||
{% for supercase in cases -%}{% for case in supercase["cases"] -%} | ||
{% set input = case["input"] -%} | ||
def test_{{ case["description"] | to_snake }}(self): | ||
{% if supercase["description"] == "verse" -%} | ||
expected = [ | ||
{{ macros.linebreak(case["expected"][0]) }} | ||
] | ||
{% else -%} | ||
expected = [recite(n, n)[0] for n in range( | ||
{{- input["startVerse"] }}, | ||
{{- input["endVerse"] + 1 }})] | ||
{% endif -%} | ||
self.assertEqual({{ case["property"]}}( | ||
{{- input["startVerse"] }}, | ||
{{- input["endVerse"] }}), expected) | ||
{% endfor %}{% endfor %} | ||
|
||
{{ macros.footer(has_error_case) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters