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
|
import sys
import unittest
import coot
import coot_utils
import coot_testing_utils
import os
sys.path.append(".")
# more general!?! append python-test dir, i.e. directory this file resides in
import inspect
this_file=inspect.getsourcefile(lambda:0)
test_dir=os.path.split(this_file)[0]
sys.path.append(test_dir)
# sys.path.append("../../coot/python-tests")
from TestPdbMtzFunctions import *
from TestShelxFunctions import *
from TestLigandFunctions import *
from TestRNAGhostsFunctions import *
from TestSSMFunctions import *
from TestNCSFunctions import *
from TestUtilsFunctions import *
from TestInternalFunctions import *
# class to write output of unittest into a 'memory file' (unittest_output)
# as well as to sys.stdout
class StreamIO:
def __init__(self, src=sys.stderr, dst=sys.stdout):
import io
global unittest_output
unittest_output = io.StringIO()
self.src = src
self.dst = dst
self.extra = unittest_output
def write(self, msg):
#self.src.write(msg)
self.extra.write(msg)
self.dst.write(msg)
def flush(self):
self.src.flush()
self.dst.flush()
self.extra.flush()
pass
suite = unittest.TestSuite()
test_list = [TestPdbMtzFunctions, TestShelxFunctions, TestLigandFunctions, TestRNAGhostsFunctions,
TestSSMFunctions, TestNCSFunctions, TestUtilsFunctions, TestInternalFunctions]
# test_list = [TestRNAGhostsFunctions]
for test in test_list:
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(test))
log = StreamIO(sys.stderr, sys.stdout)
result = unittest.TextTestRunner(stream=log, verbosity=2).run(suite)
# Shouldnt we exit!?
# cheating?! We only exit Coot if we are not in graphics mode
if (coot.use_graphics_interface_state() == 0):
if (result.wasSuccessful()):
coot.coot_real_exit(0)
else:
coot.coot_real_exit(1)
|