Skip to content

Commit 23c5f70

Browse files
committed
Tests 4 W01
1 parent 690af61 commit 23c5f70

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Week01/test_info.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
3+
4+
files = [f for f in os.listdir(os.path.dirname(__file__)) if f.startswith("info")]
5+
for f in files:
6+
exec("import " + f[:-3] + " as " + f[:-3])
7+
print(f"The module {f[:-3]} has been imported.")
8+
9+
10+
def test_names():
11+
for f in files:
12+
assert "student_id" in dir(eval(f[:-3])), (
13+
"student_id is not defined in " + f[:-3]
14+
)
15+
assert "full_name" in dir(eval(f[:-3])), "full_name is not defined in " + f[:-3]
16+
17+
18+
def test_types():
19+
for f in files:
20+
assert isinstance(eval(f[:-3]).student_id, str), (
21+
"student_id is not a string in " + f[:-3]
22+
)
23+
assert isinstance(eval(f[:-3]).full_name, str), (
24+
"full_name is not a string in " + f[:-3]
25+
)

0 commit comments

Comments
 (0)