various: comma fixes (#2150)

* 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>
This commit is contained in:
Michael Morehouse
2019-12-25 02:28:38 +00:00
committed by Corey McCandless
parent c1812833ec
commit 7a42fb71e2
14 changed files with 16 additions and 15 deletions

1
.gitignore vendored
View File

@@ -12,3 +12,4 @@ bin/configlet.exe
.cache
.pytest_cache
__pycache__
.venv

View File

@@ -3,7 +3,7 @@
{%- macro func_call(case) -%}
{{ case["property"] }}(
{% for arg in case["input"].values() %}
{{ arg }},
{{ arg }}{{- "," if not loop.last }}
{% endfor %}
)
{%- endmacro -%}

View File

@@ -10,7 +10,7 @@ import math
{%- macro formatValue(val) -%}
{% if val is iterable and val is not string -%}
ComplexNumber({% for part in val %}{{ translate_math(part) }},{% endfor %})
ComplexNumber({% for part in val %}{{ translate_math(part) }}{{ "," if not loop.last }}{% endfor %})
{%- else -%}
{{ translate_math(val) }}
{%- endif -%}

View File

@@ -4,7 +4,7 @@
{% macro tuplify(dominoes_list) -%}
[
{%- for v in dominoes_list %}
({{ v | join(', ') }}),
({{ v | join(', ') }}){{- "," if not loop.last }}
{%- endfor %}
]
{%- endmacro %}

View File

@@ -3,7 +3,7 @@
{%- set input = case["input"] -%}
def test_{{ case["description"] | to_snake }}(self):
legacy_data = { {% for key, value in case["input"]["legacy"].items() %}
{{key}}: {{value}},{% endfor %} }
{{key}}: {{value}}{{ "," if not loop.last }}{% endfor %} }
data = {{case["expected"]}}
self.assertEqual(
{{ case["property"] | to_snake }}(legacy_data), data

View File

@@ -5,7 +5,7 @@
{%- if territory_list %}
{
{%- for v in territory_list %}
({{ v | join(', ') }}),
({{ v | join(', ') }}){{ "," if not loop.last }}
{%- endfor %}
}
{%- else %}

View File

@@ -2,7 +2,7 @@
{%- macro test_call(case) %}
{{ case["property"] }}(
{% for arg in case["input"].values() -%}
"{{ arg }}",
"{{ arg }}"{{ "," if not loop.last }}
{% endfor %}
)
{% endmacro -%}

View File

@@ -2,7 +2,7 @@
{%- macro test_call(case) %}
{{ case["property"] | to_snake }}(
{% for arg in case["input"].values() -%}
"{{ arg }}",
"{{ arg }}"{{ "," if not loop.last }}
{% endfor %}
)
{% endmacro -%}

View File

@@ -13,7 +13,7 @@
garden.{{- case["property"] | to_snake -}}
("{{ input["student"] }}"),
[{% for val in case["expected"] -%}
"{{ val | camel_case }}",
"{{ val | camel_case }}"{{- "," if not loop.last }}
{% endfor %}]
)
{% endmacro -%}

View File

@@ -34,7 +34,7 @@
Tree("{{ tree["label"] }}"
{%- if tree["children"] %}, [
{%- for child_tree in tree["children"] %}
{{ write_tree(child_tree) | indent(4,True,True) }},
{{ write_tree(child_tree) | indent(4,True,True) }}{{- "," if not loop.last }}
{%- endfor %}
]{% endif %})
{%- endmacro -%}

View File

@@ -2,7 +2,7 @@
{%- macro test_call(case) %}
{{ case["property"] | to_snake }}(
{% for arg in case["input"].values() -%}
{{ arg }},
{{ arg }}{{- "," if not loop.last }}
{% endfor %}
)
{% endmacro -%}

View File

@@ -12,9 +12,9 @@ class {{ exercise | camel_case }}Test(unittest.TestCase):
payload = json.dumps({{ input["payload"] }})
{%- endif %}
response = api.{{ case["property"] }}(
"{{ input["url"] }}",
"{{ input["url"] }}"
{%- if "payload" in input %}
payload,
, payload
{%- endif %}
)
expected = {{ case["expected"] }}

View File

@@ -12,7 +12,7 @@ class {{ exercise | camel_case }}Test(unittest.TestCase):
(
{{ case["expected"]["moves"] }},
"{{ case["expected"]["goalBucket"] }}",
{{ case["expected"]["otherBucket"] }},
{{ case["expected"]["otherBucket"] }}
))
{% endfor %}

View File

@@ -3,7 +3,7 @@
{%- macro list_int_to_hex(integers) %}
[
{% for integer in integers -%}
{{ "0x{:x}".format(integer) }},
{{ "0x{:x}".format(integer) }}{{- "," if not loop.last }}
{% endfor %}
]
{% endmacro -%}