From 8ab3fcfe7c28dff1b0dbcd01b4a36f34578017a4 Mon Sep 17 00:00:00 2001
From: Janik Zikovsky <zikovskyjl@ornl.gov>
Date: Fri, 13 Jan 2012 10:25:05 -0500
Subject: [PATCH] Refs #4448: Re-enable MantidPlot tests that crashed with new
 pythonAPI

---
 Code/Mantid/MantidPlot/CMakeLists.txt         |  4 ++--
 .../MantidPlot/test/MantidPlotFoldersTest.py  |  3 ---
 .../test/MantidPlotSliceViewerTest.py         | 21 ++++++-------------
 .../Mantid/MantidPlot/test/mantidplottests.py |  5 +++++
 4 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/Code/Mantid/MantidPlot/CMakeLists.txt b/Code/Mantid/MantidPlot/CMakeLists.txt
index fdcc833a467..d3e6a60ac3a 100644
--- a/Code/Mantid/MantidPlot/CMakeLists.txt
+++ b/Code/Mantid/MantidPlot/CMakeLists.txt
@@ -828,11 +828,11 @@ add_custom_command ( TARGET MantidPlot POST_BUILD
 
 # List of .py files than must be run WITHIN MantidPlot.
 set ( MANTIDPLOT_TEST_PY_FILES 
-	#MantidPlotSliceViewerTest.py #FIXME: Only works with old-style python API as of Jan 10, 2012
+	MantidPlotSliceViewerTest.py 
 	MantidPlot1DPlotTest.py
 	MantidPlotProxiesTest.py
 	MantidPlotPythonImportTest.py
-	#MantidPlotFoldersTest.py #FIXME: Only works with old-style python API as of Jan 10, 2012
+	MantidPlotFoldersTest.py 
 )
 
 if ( 0 )
diff --git a/Code/Mantid/MantidPlot/test/MantidPlotFoldersTest.py b/Code/Mantid/MantidPlot/test/MantidPlotFoldersTest.py
index 59cd34220f3..8411c5c31b8 100644
--- a/Code/Mantid/MantidPlot/test/MantidPlotFoldersTest.py
+++ b/Code/Mantid/MantidPlot/test/MantidPlotFoldersTest.py
@@ -4,9 +4,6 @@ folders.
 """
 import mantidplottests
 from mantidplottests import *
-import time
-import numpy as np
-from PyQt4 import QtGui, QtCore
 
 class MantidPlotFoldersTest(unittest.TestCase):
     
diff --git a/Code/Mantid/MantidPlot/test/MantidPlotSliceViewerTest.py b/Code/Mantid/MantidPlot/test/MantidPlotSliceViewerTest.py
index 4ff9b31a005..eaa3a519302 100644
--- a/Code/Mantid/MantidPlot/test/MantidPlotSliceViewerTest.py
+++ b/Code/Mantid/MantidPlot/test/MantidPlotSliceViewerTest.py
@@ -13,17 +13,12 @@ import mantidplottests
 from mantidplottests import *
 import time
 
-good_setup = False
-try: 
-    CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='mdw')
-    FakeMDEventData(InputWorkspace="mdw",  UniformParams="1e5")
-    FakeMDEventData(InputWorkspace="mdw",  PeakParams="1e4, 2,4,6, 1.5")
-    BinMD(InputWorkspace="mdw", OutputWorkspace="uniform",  AxisAligned=1, AlignedDimX="x,0,10,30", AlignedDimY="y,0,10,30", AlignedDimZ="z,0,10,30", IterateEvents="1", Parallel="0")
-    CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='empty')
-    CreateMDWorkspace(Dimensions='4',Extents='0,10,0,10,0,10,0,10',Names='x,y,z,e',Units='m,m,m,meV',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='md4')
-    good_setup = True
-except:
-    pass
+CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='mdw')
+FakeMDEventData(InputWorkspace="mdw",  UniformParams="1e5")
+FakeMDEventData(InputWorkspace="mdw",  PeakParams="1e4, 2,4,6, 1.5")
+BinMD(InputWorkspace="mdw", OutputWorkspace="uniform",  AxisAligned=True, AlignedDimX="x,0,10,30", AlignedDimY="y,0,10,30", AlignedDimZ="z,0,10,30", IterateEvents="1", Parallel="0")
+CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='empty')
+CreateMDWorkspace(Dimensions='4',Extents='0,10,0,10,0,10,0,10',Names='x,y,z,e',Units='m,m,m,meV',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='md4')
 
 class MantidPlotSliceViewerTest(unittest.TestCase):
     
@@ -34,10 +29,6 @@ class MantidPlotSliceViewerTest(unittest.TestCase):
         closeAllSliceViewers()
         pass
     
-    def test_good_setup(self):
-        global good_setup
-        self.assertTrue(good_setup, "Data was setup correctly")
-
     def test_plotSlice(self):
         """ Basic plotSlice() usage """
         svw = plotSlice('uniform')
diff --git a/Code/Mantid/MantidPlot/test/mantidplottests.py b/Code/Mantid/MantidPlot/test/mantidplottests.py
index 9621877dce3..86ad36c06a8 100644
--- a/Code/Mantid/MantidPlot/test/mantidplottests.py
+++ b/Code/Mantid/MantidPlot/test/mantidplottests.py
@@ -147,6 +147,11 @@ def runTests(classname):
     #Run using either runner
     res = runner.run(suite)
     
+    # Process some events that ensure MantidPlot closes properly.
+    QtCore.QCoreApplication.processEvents()
+    QtCore.QCoreApplication.processEvents()
+    QtCore.QCoreApplication.processEvents()
+    
     # Set Mantid exit code
     if not res.wasSuccessful():
         qti.app.setExitCode(1)
-- 
GitLab