* Corrected small typos around resistor bands. * Due to failing CI, alterations to the test generator script were needed. The generated vs submitted diff now skips the first three lines of the file so that the generation date is not picked up and flagged as needing regeneration. Sadly, a workaround was also needed to prevent Python difflib from noting the difference anyways and producing an empty "false positive" diff. All templates and test files also needed to be altered to ensure that the first three lines of every test file will always be the autogeneration comment and date. Hopefully, this will now stop the CI failures without creating any subtle additional bugs. * Touch up to bowling template. Added back the error raising utility. * Touch up to two-bucket template to add back in error raising utility. [no important files changed]
47 lines
1.2 KiB
Django/Jinja
47 lines
1.2 KiB
Django/Jinja
{# Usage: {%- import "generator_macros.j2" as macros -%} #}
|
|
{# {{ macros.linebreak(text) }} #}
|
|
|
|
{%- macro linebreak(s) %}
|
|
{%- set parts = s.split(": ") -%}
|
|
"{{ parts[0] }}: "
|
|
{% for part in parts[1].split(", ") %}
|
|
"{{ part }}{% if not loop.last %}, {% endif %}"
|
|
{%- endfor %}
|
|
{% endmacro -%}
|
|
|
|
{% macro canonical_ref() -%}
|
|
# These tests are auto-generated with test data from:
|
|
# https://github.com/exercism/problem-specifications/tree/main/exercises/{{ exercise }}/canonical-data.json
|
|
# File last updated on {{ current_date }}
|
|
{%- endmacro %}
|
|
|
|
{% macro header(imports=[], ignore=[]) -%}
|
|
|
|
import unittest
|
|
|
|
from {{ exercise | to_snake }} import ({% if imports -%}
|
|
{% for name in imports -%}
|
|
{{ name }},
|
|
{% endfor %}
|
|
{%- else -%}
|
|
{% for prop in properties -%}
|
|
{%- if prop not in ignore -%}
|
|
{{ prop | to_snake }},
|
|
{%- endif -%}
|
|
{% endfor %}
|
|
{%- endif %})
|
|
{%- endmacro %}
|
|
|
|
{% macro utility() -%}# Utility functions
|
|
def assertRaisesWithMessage(self, exception):
|
|
return self.assertRaisesRegex(exception, r".+")
|
|
{%- endmacro %}
|
|
|
|
{% macro empty_set(set, list, class_name) -%}
|
|
{%- if list|length > 0 -%}
|
|
{{ set }} = {{ class_name }}({{ list }})
|
|
{%- else -%}
|
|
{{ set }} = {{ class_name }}()
|
|
{%- endif %}
|
|
{%- endmacro %}
|