-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
38 lines (33 loc) · 1.22 KB
/
Copy pathtest.py
File metadata and controls
38 lines (33 loc) · 1.22 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
import unittest
from subprocess import check_output
from Node import *
from os import listdir
from os.path import isfile, join
class TestNF(unittest.TestCase):
def normalize(self, ans):
lines = ans.split('\n')
lines = sorted(lines, key=lambda line: line.split(':')[0])
lines = filter(None, lines)
ans = ""
for line in lines:
node = line.split(':')[0]
rest = line.split(':')[1].split(',')
rest = sorted(rest)
ans += node + ":"
for stuff in rest:
ans += stuff + ","
ans = ans[:-1]
return ans
def test_topos(self):
onlyfiles = [ f for f in listdir(".") if isfile(join(".",f)) ]
for file in onlyfiles:
if file.endswith(".py") and file.startswith("topo"):
print file[:-3]
ans = check_output(["python", "run_topo.py", file[:-3], "/dev/null"])
ans = ans.split('-----')[-2]
ans = self.normalize(ans)
correct = (__import__(file[:-3]).ans)
#print "checking", ans, '\n', correct
self.assertEqual(ans, correct)
if __name__ == '__main__':
unittest.main()