-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtester.py
75 lines (72 loc) · 2.19 KB
/
tester.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
70
71
72
73
74
from subprocess import *
import os
from sys import *
from time import sleep
from colorama import *
if len(argv)==1:
print("please give the executable")
try:
input("Press enter to continue")
except SyntaxError:
pass
exit()
executable=argv[1]
print(Fore.GREEN+Style.BRIGHT+"STARTING")
print("...")
print("...")
print("tester by\nAlp Eren Yilmaz\n\n\n")
sleep(1)
true=0
false=0
def tryy(testnumber,input,output,true):
print(Fore.BLUE+Style.BRIGHT+"TEST "+str(testnumber))
print("")
print(Fore.CYAN+Style.NORMAL+"INPUT")
print("---------------------------------")
print(open(input,"r").read())
print("---------------------------------")
with open(input) as f:
data=Popen([executable],stdout=PIPE,stdin=f).communicate()[0]
f=open(output,"r")
contents=f.read()
sleep(1)
if(contents==data):
true+=1
print(Fore.GREEN+Style.BRIGHT+"TRUE")
print("")
sleep(0.5)
print(Style.NORMAL+"ANSWER:")
print("---------------------------------")
print(contents)
print("---------------------------------")
else:
print(Fore.RED+Style.BRIGHT+"FALSE")
print("")
sleep(0.5)
print(Style.NORMAL+"GIVEN RESULT:")
print("---------------------------------")
print(data)
print("---------------------------------")
print("ACTUAL RESULT:")
print("---------------------------------")
print(contents)
print("---------------------------------")
print("")
print("")
sleep(1)
return true
true=tryy(1,"tests/5-input.txt","tests/5-output.txt",true)
true=tryy(2,"tests/4-input.txt","tests/4-output.txt",true)
true=tryy(3,"tests/3-input.txt","tests/3-output.txt",true)
true=tryy(4,"tests/2-input.txt","tests/2-output.txt",true)
true=tryy(5,"tests/1-input.txt","tests/1-output.txt",true)
true=tryy(6,"tests/6-input.txt","tests/6-output.txt",true)
true=tryy(7,"tests/7-input.txt","tests/7-output.txt",true)
if true==7:
print(Style.BRIGHT+Fore.GREEN+"All of them is true!")
else:
print(Fore.CYAN+Style.BRIGHT+"You have " +str(7-true)+ " wrong answer")
try:
input("Press enter to continue")
except SyntaxError:
pass