Package test_suite :: Package system_tests :: Module base_classes
[hide private]
[frames] | no frames]

Source Code for Module test_suite.system_tests.base_classes

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2010-2011 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """Base classes for the system tests.""" 
 25   
 26  # Python module imports. 
 27  from os import sep 
 28  from shutil import rmtree 
 29  from unittest import TestCase 
 30   
 31  # relax module imports. 
 32  from data import Relax_data_store; ds = Relax_data_store() 
 33  from generic_fns.reset import reset 
 34  from prompt.interpreter import Interpreter 
 35  from relax_io import delete 
 36   
 37   
38 -class SystemTestCase(TestCase):
39 """The system test base class.""" 40
41 - def __init__(self, methodName=None):
42 """Set up the test case class for the system tests.""" 43 44 # Execute the TestCase __init__ method. 45 super(SystemTestCase, self).__init__(methodName) 46 47 # A string used for classifying skipped tests. 48 self._skip_type = 'system' 49 50 # Load the interpreter. 51 self.interpreter = Interpreter(show_script=False, quit=False, raise_relax_error=True) 52 self.interpreter.populate_self() 53 self.interpreter.on(verbose=False)
54 55
56 - def script_exec(self, script):
57 """Execute a relax script within the system test framework. 58 59 @param script: The full path of the script to execute. 60 @type script: str 61 """ 62 63 # Execute the script. 64 self.interpreter.run(script_file=script)
65 66
67 - def tearDown(self):
68 """Default tearDown operation - delete temp directories and files and reset relax.""" 69 70 # Remove the temporary directories. 71 if hasattr(ds, 'tmpdir'): 72 # Delete the directory. 73 rmtree(ds.tmpdir) 74 75 # Remove the variable. 76 del ds.tmpdir 77 78 # Remove the temporary directories. 79 if hasattr(self, 'tmpdir'): 80 # Delete the directory. 81 rmtree(self.tmpdir) 82 83 # Remove the variable. 84 del self.tmpdir 85 86 # Remove temporary files. 87 if hasattr(ds, 'tmpfile'): 88 # Delete the file. 89 delete(ds.tmpfile, fail=False) 90 91 # Remove the variable. 92 del ds.tmpfile 93 94 # Remove temporary files. 95 if hasattr(self, 'tmpfile'): 96 # Delete the file. 97 delete(self.tmpfile, fail=False) 98 99 # Remove the variable. 100 del self.tmpfile 101 102 # Reset relax. 103 reset()
104