* forth: reinstate seperate classes The template removed seperate classes per major case, resulting in several tests with duplicate names and therefore an incomplete test suite. This reinstates the distinct classes. Fixes #2148 * forth: minor black issue Was accidentally running on a later version of Black than the one specified in our requirements-generator.txt. * various: fixes trailing comma issues An upcoming change in Black revealed that we were adding unnecessary trailing commas. These will _not_ be trimmed by Black in future builds. Co-authored-by: Corey McCandless <cmccandless@users.noreply.github.com>
30 lines
804 B
Django/Jinja
30 lines
804 B
Django/Jinja
{%- import "generator_macros.j2" as macros with context -%}
|
|
|
|
{%- macro func_call(case) -%}
|
|
{{ case["property"] }}(
|
|
{% for arg in case["input"].values() %}
|
|
{{ arg }}{{- "," if not loop.last }}
|
|
{% endfor %}
|
|
)
|
|
{%- endmacro -%}
|
|
|
|
{%- macro test_case(case) -%}
|
|
{%- set expected = case["expected"] -%}
|
|
def test_{{ case["description"] | to_snake }}(self):
|
|
{%- if case is error_case %}
|
|
with self.assertRaisesWithMessage(ValueError):
|
|
{{ func_call(case) }}
|
|
{%- else %}
|
|
self.assertEqual({{ func_call(case) }}, {{ expected }})
|
|
{%- endif %}
|
|
{% endmacro %}
|
|
|
|
{{ macros.header() }}
|
|
|
|
class {{ exercise | camel_case }}Test(unittest.TestCase):
|
|
{% for case in cases -%}
|
|
{{ test_case(case) }}
|
|
{% endfor -%}
|
|
|
|
{{ macros.footer() }}
|