-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path3-say_my_name.txt
More file actions
79 lines (58 loc) · 1.96 KB
/
3-say_my_name.txt
File metadata and controls
79 lines (58 loc) · 1.96 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# 3-say_my_name.txt
# Run: python3 -m doctest -v ./tests/3-say_my_name.txt
Importing function from the module:
>>> say_my_name = __import__('3-say_my_name').say_my_name
Passing first_name and last_name correctly
>>> say_my_name("Betty", "Holberton")
My name is Betty Holberton
Passing first_name and last_name correctly 2
>>> say_my_name("Hannibal")
My name is Hannibal
Passing None as the last_name
>>> say_my_name("John", None)
Traceback (most recent call last):
...
TypeError: last_name must be a string
Passing None as the first_name
>>> say_my_name(None)
Traceback (most recent call last):
...
TypeError: first_name must be a string
Passing a number as the first_name
>>> say_my_name(1)
Traceback (most recent call last):
...
TypeError: first_name must be a string
Passing a number as the last_name
>>> say_my_name("Betty", 0)
Traceback (most recent call last):
...
TypeError: last_name must be a string
Missing two arguments
>>> say_my_name()
Traceback (most recent call last):
...
TypeError: say_my_name() missing 1 required positional argument: 'first_name'
Test other data types:
>>> say_my_name(123, "Last")
Traceback (most recent call last):
...
TypeError: first_name must be a string
>>> say_my_name("Saitama", ["Genos", "No"])
Traceback (most recent call last):
...
TypeError: last_name must be a string
Test extra args:
>>> say_my_name("Saitama", "Genos", "extra")
Traceback (most recent call last):
...
TypeError: say_my_name() takes from 1 to 2 positional arguments but 3 were given
Test too few args
>>> say_my_name()
Traceback (most recent call last):
...
TypeError: say_my_name() missing 1 required positional argument: 'first_name'
>>> say_my_name(None)
Traceback (most recent call last):
...
TypeError: first_name must be a string