2019-08-07 09:45:02 -04:00
|
|
|
{%- import "generator_macros.j2" as macros with context -%}
|
2019-07-29 23:42:12 -05:00
|
|
|
{%- macro test_call(case) %}
|
2019-08-07 09:45:02 -04:00
|
|
|
{{ case["property"] }}(
|
2019-07-29 23:42:12 -05:00
|
|
|
{% for arg in case["input"].values() -%}
|
2019-12-25 02:28:38 +00:00
|
|
|
"{{ arg }}"{{ "," if not loop.last }}
|
2019-07-29 23:42:12 -05:00
|
|
|
{% endfor %}
|
|
|
|
|
)
|
|
|
|
|
{% endmacro -%}
|
2019-08-07 09:45:02 -04:00
|
|
|
{{ macros.header() }}
|
2019-07-29 23:42:12 -05:00
|
|
|
|
|
|
|
|
class {{ exercise | camel_case }}Test(unittest.TestCase):
|
|
|
|
|
{% for case in cases -%}
|
|
|
|
|
def test_{{ case["description"] | to_snake }}(self):
|
|
|
|
|
{%- if case is error_case %}
|
|
|
|
|
with self.assertRaisesWithMessage(ValueError):
|
|
|
|
|
{{- test_call(case) }}
|
|
|
|
|
{%- else %}
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
{{- test_call(case) }},
|
|
|
|
|
{{ case["expected"] }}
|
|
|
|
|
)
|
|
|
|
|
{%- endif %}
|
|
|
|
|
{% endfor %}
|
|
|
|
|
|
2019-08-07 09:45:02 -04:00
|
|
|
{{ macros.footer() }}
|