Changeset 08f921e in sasview
- Timestamp:
- Oct 23, 2018 5:49:09 AM (6 years ago)
- Branches:
- unittest-saveload
- Children:
- 6af5d75
- Parents:
- add6365
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/projectsaveandload/test/utest_project.py
r497e06d r08f921e 7 7 import unittest 8 8 import warnings 9 if sys.version_info[0] >= 3: 10 from io import StringIO 11 else: 12 from StringIO import StringIO 9 import threading 13 10 14 11 from sas.sascalc.dataloader.loader import Loader … … 34 31 self.data1d = self.loader.load("test_data/data1D.h5") 35 32 self.data2d = self.loader.load("test_data/data2D.h5") 33 self.sasviewThread = sasviewThread() 34 self.sasviewThread.start_local() 36 35 if not (os.path.isdir(TEMP_FOLDER)): 37 36 os.makedirs(TEMP_FOLDER) 37 38 def tearDown(self): 39 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 pass 38 45 39 46 def remove_dir(self): … … 45 52 Test saving and loading a project with a single data set sent to fitting 46 53 """ 54 self.sasviewThread.join(5) 47 55 self.assertTrue(1 == 1) 48 56 … … 53 61 # TODO: Send 1D to every perspective, save/load 54 62 # TODO: Save/load simultaneous/constrained fit project 63 64 65 class sasviewThread(threading.Thread): 66 """Run the MainLoop as a thread. Access the frame with self.frame.""" 67 68 def __init__(self, autoStart=True): 69 threading.Thread.__init__(self) 70 self.setDaemon(1) 71 self.start_orig = self.start 72 self.start = self.start_local 73 self.frame = None # to be defined in self.run 74 self.lock = threading.Lock() 75 self.lock.acquire() # lock until variables are set 76 if autoStart: 77 self.start() # automatically start thread on init 78 79 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() 89 90 def start_local(self): 91 self.start_orig() 92 # After thread has started, wait until the lock is released 93 # before returning so that functions get defined. 94 self.lock.acquire()
Note: See TracChangeset
for help on using the changeset viewer.