Skip to content

Commit

Permalink
[JinJa2] Corrected the macro used for comments on the test file. (#3373)
Browse files Browse the repository at this point in the history
* Corrected the macro for comments on the test file.
* Added current_date (utcnow()) variable available for template macros.
* Removed unnecessary datetime import from macros file.
* Regenerated all practice exercise test files to add timestamp.
* Changed `datetime.now(tz=timezone.utc)` to `datetime.now(tz=timezone.utc).date()`
* Second regeneration to remove `timestamp` and just keep `date` for test files.
[no important files changed]
  • Loading branch information
BethanyG authored Jul 14, 2023
1 parent c468f7c commit e7a6b0d
Show file tree
Hide file tree
Showing 118 changed files with 355 additions and 119 deletions.
6 changes: 4 additions & 2 deletions bin/generate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
from githelp import Repo

_py = sys.version_info
if _py.major < 3 or (_py.major == 3 and _py.minor < 6):
print("Python version must be at least 3.6")
if _py.major < 3 or (_py.major == 3 and _py.minor < 7):
print("Python version must be at least 3.7")
sys.exit(1)

import argparse
from datetime import datetime
from datetime import timezone
import difflib
import filecmp
import importlib.util
Expand Down Expand Up @@ -393,6 +394,7 @@ def generate(
env.filters["zip"] = zip
env.filters["parse_datetime"] = parse_datetime
env.filters["escape_invalid_escapes"] = escape_invalid_escapes
env.globals["current_date"] = datetime.now(tz=timezone.utc).date()
env.tests["error_case"] = error_case
result = True
for exercise in sorted(Path("exercises/practice").glob(exercise_glob)):
Expand Down
4 changes: 3 additions & 1 deletion config/generator_macros.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
{% endmacro -%}

{% macro canonical_ref() -%}
# Tests adapted from `problem-specifications//canonical-data.json`
# 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=[]) -%}
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/acronym/acronym_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
abbreviate,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/acronym/canonical-data.json
# File last updated on 2023-07-14


class AcronymTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/affine-cipher/affine_cipher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
encode,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/affine-cipher/canonical-data.json
# File last updated on 2023-07-14


class AffineCipherTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/all-your-base/all_your_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
rebase,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/all-your-base/canonical-data.json
# File last updated on 2023-07-14


class AllYourBaseTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/allergies/allergies_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
Allergies,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/allergies/canonical-data.json
# File last updated on 2023-07-14


class AllergiesTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/alphametics/alphametics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
solve,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/alphametics/canonical-data.json
# File last updated on 2023-07-14


class AlphameticsTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/anagram/anagram_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
find_anagrams,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/anagram/canonical-data.json
# File last updated on 2023-07-14


class AnagramTest(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
is_armstrong_number,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/armstrong-numbers/canonical-data.json
# File last updated on 2023-07-14


class ArmstrongNumbersTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/atbash-cipher/atbash_cipher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
encode,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/atbash-cipher/canonical-data.json
# File last updated on 2023-07-14


class AtbashCipherTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/bank-account/bank_account_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
BankAccount,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/bank-account/canonical-data.json
# File last updated on 2023-07-14


class BankAccountTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/beer-song/beer_song_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
recite,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/beer-song/canonical-data.json
# File last updated on 2023-07-14


class BeerSongTest(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
TreeNode,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/binary-search-tree/canonical-data.json
# File last updated on 2023-07-14


class BinarySearchTreeTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/binary-search/binary_search_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
find,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/binary-search/canonical-data.json
# File last updated on 2023-07-14


class BinarySearchTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/bob/bob_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
response,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/bob/canonical-data.json
# File last updated on 2023-07-14


class BobTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/book-store/book_store_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
total,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/book-store/canonical-data.json
# File last updated on 2023-07-14


class BookStoreTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/bottle-song/bottle_song_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
recite,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/bottle-song/canonical-data.json
# File last updated on 2023-07-14


class BottleSongTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/bowling/bowling_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
BowlingGame,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/bowling/canonical-data.json
# File last updated on 2023-07-14


class BowlingTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/change/change_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
find_fewest_coins,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/change/canonical-data.json
# File last updated on 2023-07-14


class ChangeTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/circular-buffer/circular_buffer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
BufferFullException,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/circular-buffer/canonical-data.json
# File last updated on 2023-07-14


class CircularBufferTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/clock/clock_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
Clock,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/clock/canonical-data.json
# File last updated on 2023-07-14


class ClockTest(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
steps,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/collatz-conjecture/canonical-data.json
# File last updated on 2023-07-14


class CollatzConjectureTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/complex-numbers/complex_numbers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
ComplexNumber,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/complex-numbers/canonical-data.json
# File last updated on 2023-07-14


class ComplexNumbersTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/connect/connect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
ConnectGame,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/connect/canonical-data.json
# File last updated on 2023-07-14


class ConnectTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/crypto-square/crypto_square_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
cipher_text,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/crypto-square/canonical-data.json
# File last updated on 2023-07-14


class CryptoSquareTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/custom-set/custom_set_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
CustomSet,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/custom-set/canonical-data.json
# File last updated on 2023-07-14


class CustomSetTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/darts/darts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
score,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/darts/canonical-data.json
# File last updated on 2023-07-14


class DartsTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/diamond/diamond_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
rows,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/diamond/canonical-data.json
# File last updated on 2023-07-14


class DiamondTest(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
sum_of_squares,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/difference-of-squares/canonical-data.json
# File last updated on 2023-07-14


class DifferenceOfSquaresTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/diffie-hellman/diffie_hellman_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
secret,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/diffie-hellman/canonical-data.json
# File last updated on 2023-07-14


class DiffieHellmanTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/dnd-character/dnd_character_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
modifier,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/dnd-character/canonical-data.json
# File last updated on 2023-07-14


class DndCharacterTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/dominoes/dominoes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
can_chain,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/dominoes/canonical-data.json
# File last updated on 2023-07-14


class DominoesTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/etl/etl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
transform,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/etl/canonical-data.json
# File last updated on 2023-07-14


class EtlTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/flatten-array/flatten_array_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
flatten,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/flatten-array/canonical-data.json
# File last updated on 2023-07-14


class FlattenArrayTest(unittest.TestCase):
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/food-chain/food_chain_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
recite,
)

# Tests adapted from `problem-specifications//canonical-data.json`
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/food-chain/canonical-data.json
# File last updated on 2023-07-14


class FoodChainTest(unittest.TestCase):
Expand Down
Loading

0 comments on commit e7a6b0d

Please sign in to comment.