Files
python/exercises/hamming/.meta/template.j2

26 lines
777 B
Plaintext
Raw Normal View History

{%- import "generator_macros.j2" as macros with context -%}
{%- macro test_call(case) %}
{{ case["property"] }}(
{% for arg in case["input"].values() -%}
"{{ arg }}"{{ "," if not loop.last }}
{% endfor %}
)
{% endmacro -%}
{{ macros.header() }}
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 %}
{{ macros.footer() }}