~m-a-uchida/maus/RKdEdxDevel

« back to all changes in this revision

Viewing changes to tests/integration/test_xboa/test_xboa.py

  • Committer: Durga Rajaram
  • Date: 2015-03-20 08:30:19 UTC
  • mfrom: (659.1.105 release-candidate)
  • Revision ID: durga@fnal.gov-20150320083019-6wbtnk33gvpmm2zx
Tags: MAUS-v0.9.4
MAUS-v0.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# pylint: disable=E1101
21
21
 
22
22
import unittest
23
 
import ROOT
24
 
import xboa.test.XBOATest
 
23
import subprocess
 
24
import os
 
25
import glob
25
26
 
26
27
class TestXBOA(unittest.TestCase): # pylint: disable=R0904
27
28
    """
28
29
    Run the tests and check they return 0
29
30
    """
30
 
 
31
 
    def _test_xboa(self):
 
31
    def setUp(self): # pylint: disable = C0103
 
32
        """Set up; skip if no xboa installs found"""
 
33
        self.xboa_test = None
 
34
        self._get_test_target()
 
35
        if self.xboa_test == None:
 
36
            raise unittest.SkipTest("No xboa installed in third party")
 
37
 
 
38
    def _get_test_target(self):
 
39
        """
 
40
        Look for xboa versions in third_party/build of *this* MAUS install;
 
41
        if none found, return, else set self.xboa_test to the most recent
 
42
        version (as determined by folder name)
 
43
        """
 
44
        xboa_path = os.path.expandvars(
 
45
                                    "${MAUS_ROOT_DIR}/third_party/build/*xboa*")
 
46
        xboa_installs = glob.glob(xboa_path)
 
47
        if len(xboa_installs) == 0:
 
48
            # we only run tests if xboa is installed in this setup (rather than
 
49
            # installed from somewhere else)
 
50
            return
 
51
        else:
 
52
            # this loop is supposed to test on the most recent version of xboa
 
53
            # installed in case of multiple versions; or a dev version if it
 
54
            # is available
 
55
            xboa_installs = sorted(xboa_installs)
 
56
            for self.xboa_test in xboa_installs:
 
57
                if "dev" in self.xboa_test:
 
58
                    break
 
59
 
 
60
    def test_xboa(self):
32
61
        """
33
62
        Run the xboa test
34
63
        """
35
 
        ROOT.gROOT.SetBatch(True) #pylint: disable=E1101
36
 
        # xboa v0.15.3 does not have a test_all
37
 
        # calling test_old() instead to get pylint tests to pass through
38
 
        # -DR Feb 12 2014
39
 
        # passes, fails, warns = xboa.test.XBOATest.test_all()
40
 
        passes, fails, warns = xboa.test.XBOATest.test_old()
41
 
        self.assertEqual(fails, 0, msg = str((passes, fails, warns)))
42
 
        ROOT.gROOT.SetBatch(False) #pylint: disable=E1101
 
64
        os.chdir(self.xboa_test+"/test")
 
65
        subprocess.check_output(["python", "XBOATest.py"])
 
66
 
43
67
 
44
68
if __name__ == "__main__":
45
69
    unittest.main()