Skip to content

rational-numbers add template#2080

Merged
cmccandless merged 12 commits into
exercism:masterfrom
GKotfis:rational-numbers-add-template
Oct 25, 2019
Merged

rational-numbers add template#2080
cmccandless merged 12 commits into
exercism:masterfrom
GKotfis:rational-numbers-add-template

Conversation

@GKotfis
Copy link
Copy Markdown
Contributor

@GKotfis GKotfis commented Oct 22, 2019

Resovles #1975

I've a problem with template and if/elif conditions. Maybe you can help me why if conditions only works for 'Arithmetic' description? When you look at rational_numbers_test.py: 74 the tests are only rendered for for that group of cases. Other like 'Absolute value' are omitted.

@GKotfis GKotfis requested a review from a team as a code owner October 22, 2019 10:26
Copy link
Copy Markdown
Contributor

@cmccandless cmccandless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason that the non-arithmetic tests are not rendering is that the arithmetic tests are nested 3 levels deep, which you have accounted for, but the other tests are only 2 levels deep. Try this:


class {{ exercise | camel_case }}Test(unittest.TestCase):
    {% for mathtypescases in cases %}
    # Tests of type: {{ mathtypescases["description"] }}
        {% if mathtypescases["description"] == 'Arithmetic' %}
            {% for mathoperationcases in mathtypescases["cases"] %}
    # {{ mathoperationcases["description"] }}
                {% for case in mathoperationcases["cases"] %}
    {{ test_case_arithmetic(case) }}
                {% endfor %}
            {% endfor %}
        {% else %}
            {% for case in mathtypescases["cases"] %}
                {% if mathtypescases["description"] == 'Absolute value' %}
    {{ test_case_absolutevalue(case) }}
                {% elif mathtypescases["description"] == 'Exponentiation of a rational number' %}
    {{ test_case_exponentiation(case) }}
                {% endif %}
            {% endfor %}
        {% endif %}
    {% endfor %}

Comment thread exercises/rational-numbers/.meta/template.j2 Outdated
Comment thread exercises/rational-numbers/rational_numbers_test.py Outdated
Comment thread exercises/rational-numbers/rational_numbers_test.py
@cmccandless cmccandless merged commit 8fb0ae9 into exercism:master Oct 25, 2019
@GKotfis GKotfis deleted the rational-numbers-add-template branch October 25, 2019 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants