Changeset 0863065 in sasview
- Timestamp:
- Oct 25, 2018 12:09:11 PM (6 years ago)
- Branches:
- unittest-saveload
- Parents:
- 6af5d75
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/projectsaveandload/test/utest_project.py
r08f921e r0863065 4 4 5 5 import os 6 import sys7 6 import unittest 8 7 import warnings 9 8 import threading 9 from time import sleep 10 10 11 import sas.sasview.sasview as sasview 11 12 from sas.sascalc.dataloader.loader import Loader 12 13 from sas.sascalc.fit.pagestate import Reader as fit_state_reader … … 18 19 19 20 TEMP_FOLDER = "temp_folder" 21 DATA_1D = "test_data" + os.path.sep + "data1D.h5" 22 DATA_2D = "test_data" + os.path.sep + "data2D.h5" 20 23 STATE_LOADERS = [fit_state_reader, invariant_reader, pr_reader, corfunc_reader] 21 24 … … 29 32 self.addCleanup(self.remove_dir) 30 33 self.loader = Loader() 31 self.data1d = self.loader.load("test_data/data1D.h5") 32 self.data2d = self.loader.load("test_data/data2D.h5") 33 self.sasviewThread = sasviewThread() 34 self.sasviewThread.start_local() 34 self.data1d = self.loader.load(DATA_1D) 35 self.data2d = self.loader.load(DATA_2D) 36 self.sasviewThread = sasviewThread(False) 35 37 if not (os.path.isdir(TEMP_FOLDER)): 36 38 os.makedirs(TEMP_FOLDER) 39 self.sasviewThread.lock.acquire() 40 self.sasviewThread.start_local() 41 while self.sasviewThread.frame is None: 42 sleep(0.05) 43 while self.sasviewThread.frame._data_panel is None: 44 sleep(0.05) 45 # TODO: Do we need the frame to be visible to perform operations? 46 while not self.sasviewThread.frame.IsShown(): 47 sleep(2) 48 # self.sasviewThread.frame.get_data(DATA_1D) 49 # self.sasviewThread.frame.get_data(DATA_2D) 37 50 38 51 def tearDown(self): 52 self.sasviewThread.lock.release() 53 self.sasviewThread.frame = None 39 54 self.remove_dir() 40 if hasattr(self.sasviewThread, "isAlive"):41 if self.sasviewThread.isAlive():42 print("TODO: Close app directly")43 self.app.gui.Close()44 pass45 55 46 56 def remove_dir(self): … … 52 62 Test saving and loading a project with a single data set sent to fitting 53 63 """ 54 self.sasviewThread.join(5) 64 self.assertTrue(self.data1d is not None) 65 self.assertTrue(self.data2d is not None) 55 66 self.assertTrue(1 == 1) 56 67 … … 68 79 def __init__(self, autoStart=True): 69 80 threading.Thread.__init__(self) 81 self.lock = threading.Lock() 82 self.lock.acquire() # lock until variables are set 70 83 self.setDaemon(1) 71 84 self.start_orig = self.start 72 85 self.start = self.start_local 73 86 self.frame = None # to be defined in self.run 74 self.lock = threading.Lock()75 self.lock.acquire() # lock until variables are set76 87 if autoStart: 77 88 self.start() # automatically start thread on init 89 self.lock.release() 78 90 79 91 def run(self): 80 import sas.sasview.sasview as sasview 81 app = sasview.run_gui() 82 self.frame = app.frame 83 84 # define frame and release lock 85 # The lock is used to make sure that SetData is defined. 86 self.lock.release() 87 88 app.MainLoop() 92 app = sasview.run_gui(True) 93 self.frame = app.gui.frame 94 app.gui.MainLoop() 89 95 90 96 def start_local(self): 91 97 self.start_orig() 92 # After thread has started, wait until the lock is released93 # before returning so that functions get defined.94 self.lock.acquire()
Note: See TracChangeset
for help on using the changeset viewer.