From 9f00b00cefe12606183c0072409e1f8dadeca98e Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Wed, 8 Feb 2017 13:58:04 +0000 Subject: [PATCH] Ensures MantidPlot runs with python's builtin range command by default Adds a test for specifically passing a range to plotSpectrum. Refs #18746 --- MantidPlot/mantidplotrc.py | 6 ++++++ MantidPlot/test/MantidPlot1DPlotTest.py | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/MantidPlot/mantidplotrc.py b/MantidPlot/mantidplotrc.py index c4d11eeb245e..918c8ab26472 100644 --- a/MantidPlot/mantidplotrc.py +++ b/MantidPlot/mantidplotrc.py @@ -22,6 +22,12 @@ # Import MantidPlot python commands import mantidplot from mantidplot import * + try: + # The MantidPlot namespace is not ready for the python3-style range function + # so we ensure we revert back to the current built-in version + del range + except NameError: + pass # Make Mantid available import mantid diff --git a/MantidPlot/test/MantidPlot1DPlotTest.py b/MantidPlot/test/MantidPlot1DPlotTest.py index 8f8ac606addd..d24add8841b0 100644 --- a/MantidPlot/test/MantidPlot1DPlotTest.py +++ b/MantidPlot/test/MantidPlot1DPlotTest.py @@ -52,6 +52,10 @@ def test_plotSpectrum_severalSpectra(self): g = plotSpectrum("fake", [0, 1]) self.g = g + def test_plotSpectrum_range_command(self): + g = plotSpectrum("fake", range(0, 2)) + self.g = g + def test_Customized1DPlot(self): g = plotSpectrum("fake", 0, error_bars=True) l = g.activeLayer() @@ -110,4 +114,3 @@ def test_plotBin_command_with_tuple(self): # Run the unit tests mantidplottests.runTests(MantidPlot1DPlotTest) -