forked from fract4d/gnofract4d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
·105 lines (83 loc) · 3.35 KB
/
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python
# run all the tests
import os
import sys
import unittest
import re
import getopt
from fract4d import options
try:
# a hack, but seems easy enough
os.system("cp gnofract4d gnofract4d.py")
import gnofract4d
finally:
os.remove("gnofract4d.py")
print "Running all unit tests. This may take several minutes."
class Test(unittest.TestCase):
def testSetupPyVersionMatches(self):
doc = open("setup.py").read()
doc_re = re.compile(r"gnofract4d_version = '(\S+)'")
m = doc_re.search(doc)
self.failUnless(m,"setup.py doesn't specify version")
self.assertEqual(options.version, m.group(1))
def testDocVersionMatches(self):
# check the docs
doc = open("doc/gnofract4d-manual/C/gnofract4d-manual.xml").read()
doc_re = re.compile(r'\<\!ENTITY version "(\S+)"\>')
m = doc_re.search(doc)
self.failUnless(m,"doc doesn't specify version")
self.assertEqual(options.version,m.group(1), "Version mismatch")
def testWebsiteVersionMatches(self):
if not os.path.exists("website"):
# not included in source dist
return
mkweb = open("website/mkweb.py").read()
ver_re = re.compile(r'text="Version (\S+) released.')
m = ver_re.search(mkweb)
self.failUnless(m,"doc doesn't specify version")
self.assertEqual(options.version,m.group(1), "Version mismatch")
def testPkgInfoVersionMatches(self):
pki = open("PKG-INFO").read()
pk_re = re.compile(r'^Version: (\S+)', re.MULTILINE)
m = pk_re.search(pki)
self.failUnless(m,"PKG-INFO doesn't specify version")
self.assertEqual(options.version, m.group(1), "Version mismatch")
def testChangeLogVersionMatches(self):
changelog_top = open("debian/changelog").readline()
cl_re = re.compile(r'gnofract4d \(([0-9\.]+)-1ubuntu1\)')
m = cl_re.search(changelog_top)
self.failUnless(m,"changelog doesn't specify version")
self.assertEqual(options.version, m.group(1), "Version mismatch")
def testGenerateMandelbrot(self):
if os.path.exists("test.png"):
os.remove("test.png")
try:
gnofract4d.main(["-s", "test.png", "--width", "24", "-j", "12", "-q"])
self.failUnless(os.path.exists("test.png"))
finally:
if os.path.exists("test.png"):
os.remove("test.png")
def testVersionChecks(self):
self.assertEqual(False, gnofract4d.test_version(2,6,0))
self.assertEqual(True, gnofract4d.test_version(2,12,0))
self.assertEqual(True, gnofract4d.test_version(3,0,0))
self.assertEqual(False, gnofract4d.test_version(1,99,0))
self.assertEqual(False, gnofract4d.test_version(2,0,0))
self.assertEqual(False, gnofract4d.test_version(2,11,0))
def suite():
return unittest.makeSuite(Test,'test')
def main():
os.chdir('fract4d')
os.system('./test.py')
os.chdir('../fract4dgui')
os.system('./test.py')
os.chdir('../fractutils')
os.system('./test.py')
os.chdir('..')
unittest.main(defaultTest='suite')
if __name__ == '__main__':
if len(sys.argv) > 1 and sys.argv[1] == "--thisonly":
sys.argv.remove("--thisonly")
unittest.main(defaultTest='suite')
else:
main()