-
Notifications
You must be signed in to change notification settings - Fork 27
/
test.py
executable file
·58 lines (42 loc) · 1.71 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
#!/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 testDocVersionMatches(self):
# check the docs
with open("manual/config.toml") as doc:
content = doc.read()
ver_re = re.compile(r'version = "(\S+)"')
m = ver_re.search(content)
self.assertTrue(m, "manual 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
with open("website/content/_index.md") as doc:
content = doc.read()
ver_re = re.compile(r'latest: "(\S+)"')
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.defaultTestLoader.loadTestsFromTestCase(Test)
if __name__ == '__main__':
unittest.main(defaultTest='suite')