-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell_test.py
69 lines (45 loc) · 1.12 KB
/
shell_test.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import io
import os
import shell
import shutil
SANDBOX = "sandbox"
def check(test_number: int):
os.chdir(f"./tests/{test_number}")
try:
with open(f"input.txt", "r") as inp:
with open(f"output.txt", "r", encoding="utf-8") as out:
initial_dir = os.getcwd()
shutil.copytree("filesys", SANDBOX)
os.chdir(SANDBOX)
try:
result = io.StringIO("")
shell.solution(inp, result)
result.seek(0)
for expected_line in out:
real_line = result.readline()
assert real_line.strip() == expected_line.strip()
finally:
os.chdir(initial_dir)
shutil.rmtree(SANDBOX)
finally:
os.chdir("../..")
def test1():
check(1)
def test2():
check(2)
def test3():
check(3)
def test4():
check(4)
def test5():
check(5)
def test6():
check(6)
def test8():
check(8)
def test9():
check(9)
def test10():
check(10)
def test11():
check(11)