forked from fract4d/gnofract4d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
·70 lines (56 loc) · 2.24 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
#!/usr/bin/env python3
import os
import re
import subprocess
import sys
import tempfile
import unittest
import pytest
from fract4d import options
class Test(unittest.TestCase):
def testSetupPyVersionMatches(self):
doc = open("setup.py")
content = doc.read()
doc.close()
doc_re = re.compile(r"gnofract4d_version = '(\S+)'")
m = doc_re.search(content)
self.assertTrue(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")
content = doc.read()
doc.close()
doc_re = re.compile(r'\<\!ENTITY version "(\S+)"\>')
m = doc_re.search(content)
self.assertTrue(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")
content = mkweb.read()
mkweb.close()
ver_re = re.compile(r'text="Version (\S+) released.')
m = ver_re.search(content)
self.assertTrue(m, "doc doesn't specify version")
self.assertEqual(options.VERSION, m.group(1), "Version mismatch")
@pytest.mark.skipif(os.path.expandvars("${HOME}") == "${HOME}",
reason="cache_dir requires $HOME to be set")
def testGenerateMandelbrot(self):
with tempfile.TemporaryDirectory(prefix="fract4d_") as tmpdir:
test_file = os.path.join(tmpdir, "test.png")
subprocess.run([
os.path.join(os.path.dirname(sys.modules[__name__].__file__),
"gnofract4d"), "--nogui", "-s", test_file,
"--width", "24", "-j", "12", "-q"], check=True)
self.assertTrue(os.path.exists(test_file))
def suite():
return unittest.makeSuite(Test, 'test')
def main():
pytest.main(['fract4d/tests', 'fract4dgui/tests', 'fract4d_compiler/tests'])
if __name__ == '__main__':
if len(sys.argv) == 1 or sys.argv[1] != "--thisonly":
main()
unittest.main(defaultTest='suite')