-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_hello.py
47 lines (28 loc) · 1 KB
/
test_hello.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
## Testing 'hello.py'
# from hello import hello
# def test_hello():
# hello("Robby") == "hello, Robby"
## Note the code above will not work because it would not return a value (hint: no 'return' value), also in 'hello.py' originally
## How to approach code above
# from hello import hello
# def test_hello():
# hello("Robby") == "hello, Robby"
# ## Adding 'assert'
# from hello import hello
# def test_hello():
# assert hello("Robby") == "hello, Robby"
# assert hello() == "hello, world"
# ## Let's test code above to have multiple tests to obtain a clearer understanding of a potential error/bug
# from hello import hello
# def test_default():
# assert hello() == "hello, world"
# def test_argument():
# assert hello("Robby") == "hello, Robby"
## Testing for a list of names
from hello import hello
def test_default():
assert hello() == "hello, world"
def test_argument():
for name in ["Hermione", "Harry", "Ron"]:
assert hello(name) == f"hello, {name}"
## Create new