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-2014 Edward d'Auvergne                                   # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program 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 3 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # Module docstring. 
23  """Base classes for the system tests.""" 
24   
25  # Python module imports. 
26  from unittest import TestCase 
27   
28  # relax module imports. 
29  from data_store import Relax_data_store; ds = Relax_data_store() 
30  from pipe_control.reset import reset 
31  from prompt.interpreter import Interpreter 
32  from test_suite.clean_up import deletion 
33   
34   
35 -class SystemTestCase(TestCase):
36 """The system test base class.""" 37
38 - def __init__(self, methodName=None):
39 """Set up the test case class for the system tests.""" 40 41 # Execute the TestCase __init__ method. 42 super(SystemTestCase, self).__init__(methodName) 43 44 # A string used for classifying skipped tests. 45 if not hasattr(self, '_skip_type'): 46 self._skip_type = 'system' 47 48 # Load the interpreter. 49 self.interpreter = Interpreter(show_script=False, raise_relax_error=True) 50 self.interpreter.populate_self() 51 self.interpreter.on(verbose=False)
52 53
54 - def script_exec(self, script):
55 """Execute a relax script within the system test framework. 56 57 @param script: The full path of the script to execute. 58 @type script: str 59 """ 60 61 # Execute the script. 62 self.interpreter.run(script_file=script)
63 64
65 - def tearDown(self):
66 """Default tearDown operation - delete temp directories and files and reset relax.""" 67 68 # Remove the temporary directory and variable (if there is a deletion failure, continue to allow the test suite to survive). 69 try: 70 deletion(obj=ds, name='tmpdir', dir=True) 71 except: 72 pass 73 try: 74 deletion(obj=self, name='tmpdir', dir=True) 75 except: 76 pass 77 78 # Remove temporary file and variable (if there is a deletion failure, continue to allow the test suite to survive). 79 try: 80 deletion(obj=ds, name='tmpfile', dir=False) 81 except: 82 pass 83 try: 84 deletion(obj=self, name='tmpfile', dir=False) 85 except: 86 pass 87 88 # Reset relax. 89 reset()
90