Changeset bbd97e5 in sasview
- Timestamp:
- Apr 3, 2014 8:59:01 PM (11 years ago)
- 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
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
run.py
r2f2d9d0 rbbd97e5 15 15 import imp 16 16 from glob import glob 17 from contextlib import contextmanager 18 from os.path import abspath, dirname, join as joinpath 17 19 18 # find the directories for the source and build19 from distutils.util import get_platform20 root = os.path.abspath(os.path.dirname(__file__))21 platform = '%s-%s'%(get_platform(),sys.version[:3])22 build_path = os.path.join(root, 'build','lib.'+platform)23 24 # Make sure that we have a private version of mplconfig25 mplconfig = os.path.join(os.getcwd(), '.mplconfig')26 os.environ['MPLCONFIGDIR'] = mplconfig27 if not os.path.exists(mplconfig): os.mkdir(mplconfig)28 #import matplotlib29 #matplotlib.use('Agg')30 #print matplotlib.__file__31 #import pylab; pylab.hold(False)32 20 33 21 def addpath(path): … … 36 24 environment variable for subprocesses. 37 25 """ 38 path = os.path.abspath(path)26 path = abspath(path) 39 27 if 'PYTHONPATH' in os.environ: 40 28 PYTHONPATH = path + os.pathsep + os.environ['PYTHONPATH'] … … 44 32 sys.path.insert(0, path) 45 33 46 from contextlib import contextmanager47 34 @contextmanager 48 35 def cd(path): … … 57 44 def import_package(modname, path): 58 45 """Import a package into a particular point in the python namespace""" 59 mod = imp.load_source(modname, os.path.abspath(os.path.join(path,'__init__.py')))46 mod = imp.load_source(modname, abspath(joinpath(path,'__init__.py'))) 60 47 sys.modules[modname] = mod 61 mod.__path__ = [ os.path.abspath(path)]48 mod.__path__ = [abspath(path)] 62 49 return mod 63 50 … … 65 52 """Import a DLL from the build directory""" 66 53 # build_path comes from context 67 path = glob( os.path.join(build_path, *modname.split('.'))+'.*')[0]54 path = glob(joinpath(build_path, *modname.split('.'))+'.*')[0] 68 55 #print "importing", modname, "from", path 69 56 return imp.load_dynamic(modname, path) 70 57 58 def prepare(): 59 # Don't create *.pyc files 60 sys.dont_write_bytecode = True 71 61 72 # Don't create *.pyc files73 sys.dont_write_bytecode = True 62 # Debug numpy warnings 63 #import numpy; numpy.seterr(all='raise') 74 64 75 # Debug numpy warnings 76 #import numpy; numpy.seterr(all='raise') 65 # find the directories for the source and build 66 from distutils.util import get_platform 67 root = abspath(dirname(__file__)) 68 platform = '%s-%s'%(get_platform(),sys.version[:3]) 69 build_path = joinpath(root, 'build','lib.'+platform) 77 70 78 # add periodictable to the path 79 try: import periodictable 80 except: addpath(os.path.join(root, '..','periodictable')) 71 # Make sure that we have a private version of mplconfig 72 mplconfig = joinpath(abspath(dirname(__file__)), '.mplconfig') 73 os.environ['MPLCONFIGDIR'] = mplconfig 74 if not os.path.exists(mplconfig): os.mkdir(mplconfig) 75 #import matplotlib 76 #matplotlib.use('Agg') 77 #print matplotlib.__file__ 78 #import pylab; pylab.hold(False) 79 # add periodictable to the path 80 try: import periodictable 81 except: addpath(joinpath(root, '..','periodictable')) 81 82 82 # select wx version83 #addpath(os.path.join(root, '..','wxPython-src-3.0.0.0','wxPython'))83 # select wx version 84 #addpath(os.path.join(root, '..','wxPython-src-3.0.0.0','wxPython')) 84 85 85 # Build project if the build directory does not already exist.86 if not os.path.exists(build_path):87 import subprocess88 with cd(root):89 subprocess.call((sys.executable, "setup.py", "build"), shell=False)86 # Build project if the build directory does not already exist. 87 if not os.path.exists(build_path): 88 import subprocess 89 with cd(root): 90 subprocess.call((sys.executable, "setup.py", "build"), shell=False) 90 91 91 # Put the source trees on the path92 addpath(os.path.join(root, 'src'))93 addpath(os.path.join(root, 'park-1.2.1'))92 # Put the source trees on the path 93 addpath(joinpath(root, 'src')) 94 addpath(joinpath(root, 'park-1.2.1')) 94 95 95 # Import the sansview package from root/sansview as sans.sansview. It would96 # be better to just store the package in src/sans/sansview.97 import sans98 sans.sansview = import_package('sans.sansview', os.path.join(root,'sansview'))96 # Import the sansview package from root/sansview as sans.sansview. It would 97 # be better to just store the package in src/sans/sansview. 98 import sans 99 sans.sansview = import_package('sans.sansview', joinpath(root,'sansview')) 99 100 100 # The sans.models package Compiled Model files should be pulled in from the build directory even though101 # the source is stored in src/sans/models.101 # The sans.models package Compiled Model files should be pulled in from the build directory even though 102 # the source is stored in src/sans/models. 102 103 103 # Compiled modules need to be pulled from the build directory.104 # Some packages are not where they are needed, so load them explicitly.105 import sans.pr106 sans.pr.core = import_package('sans.pr.core',107 os.path.join(build_path, 'sans', 'pr', 'core'))108 #import_dll('park._modeling')104 # Compiled modules need to be pulled from the build directory. 105 # Some packages are not where they are needed, so load them explicitly. 106 import sans.pr 107 sans.pr.core = import_package('sans.pr.core', 108 joinpath(build_path, 'sans', 'pr', 'core')) 109 #import_dll('park._modeling') 109 110 110 #park = import_package('park',os.path.join(build_path,'park'))111 #park = import_package('park',os.path.join(build_path,'park')) 111 112 112 # Pull the entire sans.models package from the build directory since it contains113 # a mixture of autogenerated python and C. Any changes in models will require114 # a rebuild with setup.py build115 sans.models = import_package('sans.models', os.path.join(build_path, 'sans', 'models'))113 # Pull the entire sans.models package from the build directory since it contains 114 # a mixture of autogenerated python and C. Any changes in models will require 115 # a rebuild with setup.py build 116 sans.models = import_package('sans.models', joinpath(build_path, 'sans', 'models')) 116 117 117 sys.path.append(build_path)118 sys.path.append(build_path) 118 119 119 #print "\n".join(sys.path)120 #from sans.models import SphereModel120 #print "\n".join(sys.path) 121 #from sans.models import SphereModel 121 122 122 # Won't need freeze support when running from the source tree 123 #import multiprocessing 124 #multiprocessing.freeze_support() 125 126 # start sasview 127 from sans.sansview.sansview import SasView128 SasView()123 if __name__ == "__main__": 124 # start sasview 125 #import multiprocessing 126 #multiprocessing.freeze_support() 127 prepare() 128 from sans.sansview.sansview import SasView 129 SasView() -
test/utest_sansview.py
r21b7a49 rbbd97e5 8 8 print "xmlrunner needs to be installed to run these tests" 9 9 print "Try easy_install unittest-xml-reporting" 10 sys.exit(1) 10 11 11 12 # Check whether we have matplotlib installed … … 21 22 SKIPPED_DIRS.append("sansguiframe") 22 23 23 COMMAND_SEP = ';'24 if os.name == 'nt':25 COMMAND_SEP = '&'24 #COMMAND_SEP = ';' 25 #if os.name == 'nt': 26 # COMMAND_SEP = '&' 26 27 27 28 def run_tests(): 29 test_root = os.path.abspath(os.path.dirname(__file__)) 30 run_one_py = os.path.join(test_root, 'run_one.py') 28 31 passed = 0 29 32 failed = 0 … … 32 35 n_failures = 0 33 36 34 for d in os.listdir( os.getcwd()):37 for d in os.listdir(test_root): 35 38 36 39 # Check for modules to be skipped … … 39 42 40 43 # 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") 42 45 if os.path.isdir(module_dir): 43 46 for f in os.listdir(module_dir): … … 45 48 if os.path.isfile(file_path) and f.startswith("utest_") and f.endswith(".py"): 46 49 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) 50 51 proc = subprocess.Popen(code, shell=True, stdout=subprocess.PIPE, stderr = subprocess.STDOUT) 51 52 std_out, std_err = proc.communicate() 53 #print std_out 54 #sys.exit() 52 55 has_failed = True 53 56 m = re.search("Ran ([0-9]+) test", std_out)
Note: See TracChangeset
for help on using the changeset viewer.