Skip to content

Commit

Permalink
Refs #4316 moved code for reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
Janik Zikovsky committed Dec 23, 2011
1 parent 8eca95a commit ecde61f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
20 changes: 4 additions & 16 deletions Code/Mantid/MantidPlot/test/MantidPlotSliceViewerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
import sys
import os
import unittest
import mantidplottests
import time

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("mdw", UniformParams="1e5")
FakeMDEventData("mdw", PeakParams="1e4, 2,4,6, 1.5")
BinToMDHistoWorkspace("mdw", "uniform", 1, "x,0,10,30", "y,0,10,30", "z,0,10,30", IterateEvents="1", Parallel="0")
BinMD("mdw", "uniform", 1, "x,0,10,30", "y,0,10,30", "z,0,10,30", IterateEvents="1", Parallel="0")


class MantidPlotSliceViewerTest(unittest.TestCase):
Expand Down Expand Up @@ -77,18 +78,5 @@ def test_getSliceViewer_failure(self):
svw = plotSlice('uniform', label='alabel')
self.assertRaises(Exception, getSliceViewer, 'uniform', 'different_label')


# Custom code to create and run this single test suite
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(MantidPlotSliceViewerTest) )
# Get the XML runner if the environment variable was set
src = os.getenv('MANTID_SOURCE')
if src is None:
runner = unittest.TextTestRunner()
else:
sys.path.append( os.path.join(src, "TestingTools/unittest-xml-reporting/src") )
import xmlrunner
runner = xmlrunner.XMLTestRunner(output='Testing')
#Run using either runner
runner.run(suite)

# Run the unit tests
mantidplottests.runTests(MantidPlotSliceViewerTest)
26 changes: 26 additions & 0 deletions Code/Mantid/MantidPlot/test/mantidplottests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Utility functions for running python test scripts
inside MantidPlot.
"""
import sys
import os
import unittest
import time

def runTests(classname):
""" Run the test suite in the class.
Uses the XML runner if the MANTID_SOURCE environment variable was set.
"""
# Custom code to create and run this single test suite
suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite(classname) )
# Get the XML runner if the environment variable was set
src = os.getenv('MANTID_SOURCE')
if src is None:
runner = unittest.TextTestRunner()
else:
sys.path.append( os.path.join(src, "TestingTools/unittest-xml-reporting/src") )
import xmlrunner
runner = xmlrunner.XMLTestRunner(output='Testing')
#Run using either runner
runner.run(suite)

0 comments on commit ecde61f

Please sign in to comment.