| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 425d50a commit 69a571f
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,10 @@ | |||
| 1 | + {# Usage: {%- import "generator_macros.j2" as macros -%} #} | ||
| 2 | + {# {{ macros.canonical_ref(version) }} #} | ||
| 3 | + | ||
| 4 | + {% macro canonical_ref(version) -%} | ||
| 5 | + # Tests adapted from `problem-specifications//canonical-data.json` @ v{{ version }} | ||
| 6 | + {%- endmacro %} | ||
| 7 | + | ||
| 1 | 8 | {% macro utility() -%}# Utility functions | |
| 2 | 9 | def setUp(self): | |
| 3 | 10 | try: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,29 @@ | |||
| 1 | + {%- import "generator_macros.j2" as macros -%} | ||
| 2 | + {%- macro test_call(case) %} | ||
| 3 | + {{ case["property"] | to_snake }}( | ||
| 4 | + {% for arg in case["input"].values() -%} | ||
| 5 | + "{{ arg }}", | ||
| 6 | + {% endfor %} | ||
| 7 | + ) | ||
| 8 | + {% endmacro -%} | ||
| 9 | + import unittest | ||
| 10 | + | ||
| 11 | + from {{ exercise | to_snake }} import {% for prop in properties -%} | ||
| 12 | + {{ prop | to_snake }}{% if not loop.last %}, {% endif -%} | ||
| 13 | + {% endfor %} | ||
| 14 | + | ||
| 15 | + {{ macros.canonical_ref(version) }} | ||
| 16 | + | ||
| 17 | + class {{ exercise | camel_case }}Test(unittest.TestCase): | ||
| 18 | + {# All test cases in this exercise are nested, so use two for loops -#} | ||
| 19 | + {% for case in cases -%}{% for case in case["cases"] -%} | ||
| 20 | + def test_{{ case["description"] | to_snake }}(self): | ||
| 21 | + self.assertIs( | ||
| 22 | + {{- test_call(case) }}, | ||
| 23 | + {{ case["expected"] }} | ||
| 24 | + ) | ||
| 25 | + {% endfor %}{% endfor %} | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + if __name__ == '__main__': | ||
| 29 | + unittest.main() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,11 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | 3 | from isogram import is_isogram | |
| 4 | 4 | ||
| 5 | - | ||
| 6 | 5 | # Tests adapted from `problem-specifications//canonical-data.json` @ v1.7.0 | |
| 7 | 6 | ||
| 8 | - class IsogramTest(unittest.TestCase): | ||
| 9 | 7 | ||
| 8 | + class IsogramTest(unittest.TestCase): | ||
| 10 | 9 | def test_empty_string(self): | |
| 11 | 10 | self.assertIs(is_isogram(""), True) | |
| 12 | 11 | ||
@@ -16,7 +15,7 @@ def test_isogram_with_only_lower_case_characters(self): | |||
| 16 | 15 | def test_word_with_one_duplicated_character(self): | |
| 17 | 16 | self.assertIs(is_isogram("eleven"), False) | |
| 18 | 17 | ||
| 19 | - def test_word_with_one_duplicated_character_from_end_of_alphabet(self): | ||
| 18 | + def test_word_with_one_duplicated_character_from_the_end_of_the_alphabet(self): | ||
| 20 | 19 | self.assertIs(is_isogram("zzyzx"), False) | |
| 21 | 20 | ||
| 22 | 21 | def test_longest_reported_english_isogram(self): | |
@@ -25,13 +24,13 @@ def test_longest_reported_english_isogram(self): | |||
| 25 | 24 | def test_word_with_duplicated_character_in_mixed_case(self): | |
| 26 | 25 | self.assertIs(is_isogram("Alphabet"), False) | |
| 27 | 26 | ||
| 28 | - def test_word_with_duplicated_letter_in_mixed_case_lowercase_first(self): | ||
| 27 | + def test_word_with_duplicated_character_in_mixed_case_lowercase_first(self): | ||
| 29 | 28 | self.assertIs(is_isogram("alphAbet"), False) | |
| 30 | 29 | ||
| 31 | 30 | def test_hypothetical_isogrammic_word_with_hyphen(self): | |
| 32 | 31 | self.assertIs(is_isogram("thumbscrew-japingly"), True) | |
| 33 | 32 | ||
| 34 | - def test_hypothetical_word_with_duplicate_character_following_hyphen(self): | ||
| 33 | + def test_hypothetical_word_with_duplicated_character_following_hyphen(self): | ||
| 35 | 34 | self.assertIs(is_isogram("thumbscrew-jappingly"), False) | |
| 36 | 35 | ||
| 37 | 36 | def test_isogram_with_duplicated_hyphen(self): | |
@@ -46,11 +45,6 @@ def test_duplicated_character_in_the_middle(self): | |||
| 46 | 45 | def test_same_first_and_last_characters(self): | |
| 47 | 46 | self.assertIs(is_isogram("angola"), False) | |
| 48 | 47 | ||
| 49 | - # Additional tests for this track | ||
| 50 | - | ||
| 51 | - def test_isogram_with_duplicated_letter_and_nonletter_character(self): | ||
| 52 | - self.assertIs(is_isogram("Aleph Bot Chap"), False) | ||
| 53 | - | ||
| 54 | 48 | ||
| 55 | - if __name__ == '__main__': | ||
| 49 | + if __name__ == "__main__": | ||
| 56 | 50 | unittest.main() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments