-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestInput.py
More file actions
68 lines (56 loc) · 1.53 KB
/
TestInput.py
File metadata and controls
68 lines (56 loc) · 1.53 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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import fileinput
import test
def exportTest():
print ("exporting")
def importTest():
print ("importing")
with fileinput.input(files=("practiceTest.txt", "practiceTest1.txt")) as f:
questions = False
readingQuestion = False
readMultiupleChoice = False
question = ''
multipleChoice = []
header = ''
questionList = []
for line in f:
if not questions:
if line.startswith('1.'):
questions = True
else:
#all of the header crap about the test
header += line
if questions:
if line.startswith(' '):
continue
if line.startswith('a.'):
readingQuestion = False
readMultiupleChoice = True
if line[0].isdigit():
readingQuestion = True
readMultiupleChoice = False
if line.startswith('answer:'):
readMultiupleChoice = False
readingQuestion = False
answer = line[7:]
questionList.append(test.Question(question, answer, multipleChoice))
question = ''
answer = ''
multipleChoice = []
continue
if readingQuestion:
# strip the number off the begining
question += line[3:] #for single digit numbers this produces a space in front
if readMultiupleChoice:
if not line.startswith('\n'):
# strip the letter off of the multiple choice
multipleChoice.append(line[3:])
print (len(questionList))
print ('questions list')
for q in questionList:
print (q.question,q.multipleChoice,q.answer)
def combineTests():
print ("combineTests")
importTest()