Changeset bbd97e5 in sasview for test/utest_sansview.py


Ignore:
Timestamp:
Apr 3, 2014 6:59:01 PM (10 years ago)
Author:
pkienzle
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
eea06fe
Parents:
27b7acc
Message:

Allow tests to be run without installing sasview

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/utest_sansview.py

    r21b7a49 rbbd97e5  
    88    print "xmlrunner needs to be installed to run these tests" 
    99    print "Try easy_install unittest-xml-reporting" 
     10    sys.exit(1) 
    1011 
    1112# Check whether we have matplotlib installed 
     
    2122    SKIPPED_DIRS.append("sansguiframe") 
    2223 
    23 COMMAND_SEP = ';' 
    24 if os.name == 'nt': 
    25     COMMAND_SEP = '&' 
     24#COMMAND_SEP = ';' 
     25#if os.name == 'nt': 
     26#    COMMAND_SEP = '&' 
    2627 
    2728def run_tests(): 
     29    test_root = os.path.abspath(os.path.dirname(__file__)) 
     30    run_one_py = os.path.join(test_root, 'run_one.py') 
    2831    passed = 0 
    2932    failed = 0 
     
    3235    n_failures = 0 
    3336     
    34     for d in os.listdir(os.getcwd()): 
     37    for d in os.listdir(test_root): 
    3538         
    3639        # Check for modules to be skipped 
     
    3942         
    4043        # Go through modules looking for unit tests 
    41         module_dir = os.path.join(os.getcwd(),d,"test") 
     44        module_dir = os.path.join(test_root, d, "test") 
    4245        if os.path.isdir(module_dir): 
    4346            for f in os.listdir(module_dir): 
     
    4548                if os.path.isfile(file_path) and f.startswith("utest_") and f.endswith(".py"): 
    4649                    module_name,_ = os.path.splitext(f) 
    47                     code = "cd %s%s%s -c \"import sys;import xmlrunner;import unittest;sys.path.insert(0, '%s');" % (module_dir, COMMAND_SEP, sys.executable, module_dir) 
    48                     code += "from %s import *;" % module_name 
    49                     code += "unittest.main(testRunner=xmlrunner.XMLTestRunner(output='logs'))\"" 
     50                    code = '"%s" %s %s'%(sys.executable, run_one_py, file_path) 
    5051                    proc = subprocess.Popen(code, shell=True, stdout=subprocess.PIPE, stderr = subprocess.STDOUT) 
    5152                    std_out, std_err = proc.communicate() 
     53                    #print std_out 
     54                    #sys.exit() 
    5255                    has_failed = True 
    5356                    m = re.search("Ran ([0-9]+) test", std_out) 
Note: See TracChangeset for help on using the changeset viewer.