Author: bugman Date: Wed Jun 29 19:58:36 2011 New Revision: 13322 URL: http://svn.gna.org/viewcvs/relax?rev=13322&view=rev Log: Shifted the GUI test check_exceptions() method into a base class for all tests to use. Added: branches/gui_testing/test_suite/gui_tests/base_classes.py - copied, changed from r13321, branches/gui_testing/test_suite/gui_tests/noe.py Modified: branches/gui_testing/test_suite/gui_tests/noe.py branches/gui_testing/test_suite/gui_tests/rx.py Copied: branches/gui_testing/test_suite/gui_tests/base_classes.py (from r13321, branches/gui_testing/test_suite/gui_tests/noe.py) URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/test_suite/gui_tests/base_classes.py?p2=branches/gui_testing/test_suite/gui_tests/base_classes.py&p1=branches/gui_testing/test_suite/gui_tests/noe.py&r1=13321&r2=13322&rev=13322&view=diff ============================================================================== --- branches/gui_testing/test_suite/gui_tests/noe.py (original) +++ branches/gui_testing/test_suite/gui_tests/base_classes.py Wed Jun 29 19:58:36 2011 @@ -20,59 +20,20 @@ # # ############################################################################### +# Module docstring. +"""Base classes for the GUI tests.""" + # Python module imports. -from os import F_OK, access, sep import Queue -from shutil import rmtree -from tempfile import mkdtemp -from time import sleep from traceback import print_exception from unittest import TestCase -import wx - -# Dependency checks. -import dep_check # relax module imports. -from data import Relax_data_store; ds = Relax_data_store() -from generic_fns.mol_res_spin import spin_loop -from generic_fns.pipes import cdp_name from status import Status; status = Status() -# relax GUI imports. -if dep_check.wx_module: - from gui.relax_gui import Main -from gui.misc import str_to_gui - -class Noe(TestCase): - """Class for testing various aspects specific to the NOE analysis.""" - - def setUp(self): - """Set up for all the functional tests.""" - - # Create a temporary directory for the results. - ds.tmpdir = mkdtemp() - - # Start the GUI. - self.app = wx.App() - - # Build the GUI. - self.gui = Main(parent=None, id=-1, title="") - - - def tearDown(self): - """Reset the relax data storage object.""" - - # Remove the temporary directory. - rmtree(ds.tmpdir) - - # Reset the relax data storage object. - ds.__reset__() - - # Destroy the GUI. - self.gui.Destroy() - +class GuiTestCase(TestCase): + """The GUI specific test case.""" def check_exceptions(self): """Check that no exception has occurred.""" @@ -93,84 +54,3 @@ # No exception. except Queue.Empty: pass - - - def test_noe_analysis(self): - """Test the NOE analysis.""" - - # Directly set up the analysis. - self.gui.analysis.new_analysis(analysis_type='noe', analysis_name="Steady-state NOE test", pipe_name='noe test') - - # Alias the page. - page = self.gui.analysis.get_page_from_name("Steady-state NOE test") - - # The frequency label. - page.field_nmr_frq.SetValue(str_to_gui('500')) - - # Change the results directory. - page.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) - - # The sequence file. - file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'Ap4Aase.seq' - page.field_sequence.SetValue(str_to_gui(file)) - - # Unresolved spins. - page.field_unresolved.SetValue(str_to_gui('3')) - - # The reference spectrum. - file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'ref_ave.list' - page.field_ref_noe.SetValue(str_to_gui(file)) - - # The sat spectrum. - file = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'peak_lists' + sep + 'sat_ave.list' - page.field_sat_noe.SetValue(str_to_gui(file)) - - # Set the errors. - page.field_ref_rmsd.SetValue(str_to_gui('3600')) - page.field_sat_rmsd.SetValue(str_to_gui('3000')) - - # Set the proton name. - ds.relax_gui.global_setting[3] = 'HN' - - # Execute relax. - page.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, page.button_exec_id)) - - # Wait for execution to complete. - page.thread.join() - - # Exceptions in the thread. - self.check_exceptions() - - # The real data. - res_nums = [4, 5, 6] - sat = [5050.0, 51643.0, 53663.0] - ref = [148614.0, 166842.0, 128690.0] - noe = [0.033980647852826784, 0.30953237194471417, 0.4169943274535706] - noe_err = [0.02020329903276632, 0.019181416098790607, 0.026067523940084526] - - # Check the data pipe. - self.assertEqual(cdp_name(), ds.relax_gui.analyses[0].pipe_name) - - # Check the data. - i = 0 - for spin, mol_name, res_num, res_name in spin_loop(full_info=True): - # Skip deselected spins. - if not spin.select: - continue - - # Spin info. - self.assertEqual(res_nums[i], res_num) - - # Check the intensity data. - self.assertEqual(sat[i], spin.intensities['sat']) - self.assertEqual(ref[i], spin.intensities['ref']) - - # Check the NOE data. - self.assertEqual(noe[i], spin.noe) - self.assertEqual(noe_err[i], spin.noe_err) - - # Increment the spin index. - i += 1 - - # Check the created files. - self.assert_(access(ds.tmpdir+sep+'grace'+sep+'noe.agr', F_OK)) Modified: branches/gui_testing/test_suite/gui_tests/noe.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/test_suite/gui_tests/noe.py?rev=13322&r1=13321&r2=13322&view=diff ============================================================================== --- branches/gui_testing/test_suite/gui_tests/noe.py (original) +++ branches/gui_testing/test_suite/gui_tests/noe.py Wed Jun 29 19:58:36 2011 @@ -27,13 +27,13 @@ from tempfile import mkdtemp from time import sleep from traceback import print_exception -from unittest import TestCase import wx # Dependency checks. import dep_check # relax module imports. +from base_classes import GuiTestCase from data import Relax_data_store; ds = Relax_data_store() from generic_fns.mol_res_spin import spin_loop from generic_fns.pipes import cdp_name @@ -45,7 +45,7 @@ from gui.misc import str_to_gui -class Noe(TestCase): +class Noe(GuiTestCase): """Class for testing various aspects specific to the NOE analysis.""" def setUp(self): @@ -72,27 +72,6 @@ # Destroy the GUI. self.gui.Destroy() - - - def check_exceptions(self): - """Check that no exception has occurred.""" - - # Check. - try: - # Get the exception from the queue. - index, exc = status.analyses.exception_queue.get(block=False) - - # Print it. - print("Exception raised in thread.\n") - print_exception(exc[0], exc[1], exc[2]) - print("\n\n") - - # Fail. - self.fail() - - # No exception. - except Queue.Empty: - pass def test_noe_analysis(self): Modified: branches/gui_testing/test_suite/gui_tests/rx.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/test_suite/gui_tests/rx.py?rev=13322&r1=13321&r2=13322&view=diff ============================================================================== --- branches/gui_testing/test_suite/gui_tests/rx.py (original) +++ branches/gui_testing/test_suite/gui_tests/rx.py Wed Jun 29 19:58:36 2011 @@ -27,13 +27,13 @@ from tempfile import mkdtemp from time import sleep from traceback import print_exception -from unittest import TestCase import wx # Dependency checks. import dep_check # relax module imports. +from base_classes import GuiTestCase from data import Relax_data_store; ds = Relax_data_store() from generic_fns.mol_res_spin import spin_loop from generic_fns.pipes import cdp_name @@ -45,7 +45,7 @@ from gui.misc import float_to_gui, int_to_gui, str_to_gui -class Rx(TestCase): +class Rx(GuiTestCase): """Class for testing various aspects specific to the R1 and R2 analyses.""" def setUp(self): @@ -72,27 +72,6 @@ # Destroy the GUI. self.gui.Destroy() - - - def check_exceptions(self): - """Check that no exception has occurred.""" - - # Check. - try: - # Get the exception from the queue. - index, exc = status.analyses.exception_queue.get(block=False) - - # Print it. - print("Exception raised in thread.\n") - print_exception(exc[0], exc[1], exc[2]) - print("\n\n") - - # Fail. - self.fail() - - # No exception. - except Queue.Empty: - pass def test_r1_analysis(self):