Files
python/exercises/practice/hello-world/hello_world_test.py
BethanyG be794198e1 [Resistor Color Expert]: Corrected Small Typos (#3469)
* 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]
2023-07-21 16:54:40 -07:00

31 lines
1.1 KiB
Python

# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/hello-world/canonical-data.json
# File last updated on 2023-07-19
import unittest
try:
from hello_world import (
hello,
)
except ImportError as import_fail:
message = import_fail.args[0].split("(", maxsplit=1)
item_name = import_fail.args[0].split()[3]
item_name = item_name[:-1] + "()'"
# pylint: disable=raise-missing-from
raise ImportError(
"\n\nMISSING FUNCTION --> In your 'hello_world.py' file, we can not find or import the"
f" function named {item_name}. \nThe tests for this first exercise expect a function that"
f' returns the string "Hello, World!"'
f'\n\nDid you use print("Hello, World!") instead?'
) from None
class HelloWorldTest(unittest.TestCase):
def test_say_hi(self):
msg = "\n\nThis test expects a return of the string 'Hello, World!' \nDid you use print('Hello, World!') by mistake?"
self.assertEqual(hello(), "Hello, World!", msg=msg)