Author: bugman Date: Tue Jan 4 10:45:41 2011 New Revision: 12113 URL: http://svn.gna.org/viewcvs/relax?rev=12113&view=rev Log: The RelaxTestLoader has been added as a replacement for unittest.TestLoader. This empty class will in the end handle the skipping of tests when Python packages optional for relax are not installed. The unit_test_runner uses this class if it can import it, otherwise it falls back to unittest.TestLoader to allow for non-relax usage. Added: 1.3/test_suite/relax_test_loader.py Modified: 1.3/test_suite/unit_tests/unit_test_runner.py Added: 1.3/test_suite/relax_test_loader.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/relax_test_loader.py?rev=12113&view=auto ============================================================================== --- 1.3/test_suite/relax_test_loader.py (added) +++ 1.3/test_suite/relax_test_loader.py Tue Jan 4 10:45:41 2011 @@ -1,0 +1,35 @@ +################################################################################ +# # +# Copyright (C) 2007-2011 Edward d'Auvergne # +# # +# # +# This file is part of the program relax. # +# # +# relax is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# relax is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with relax; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +################################################################################ + +# Module docstring. +"""Replacement unittest.TestLoader class. + +This is to handle skipping of tests when Python modules are not installed. +""" + +# Python module imports +from unittest import TestLoader + + +class RelaxTestLoader(TestLoader): + """Replacement TestLoader class.""" Modified: 1.3/test_suite/unit_tests/unit_test_runner.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/unit_test_runner.py?rev=12113&r1=12112&r2=12113&view=diff ============================================================================== --- 1.3/test_suite/unit_tests/unit_test_runner.py (original) +++ 1.3/test_suite/unit_tests/unit_test_runner.py Tue Jan 4 10:45:41 2011 @@ -59,6 +59,12 @@ from optparse import OptionParser from textwrap import dedent +# relax module imports. +try: + from relax_test_loader import RelaxTestLoader as TestLoader +except ImportError: + from unittest import TestLoader + # constants ########### @@ -307,7 +313,7 @@ clazz = getattr(packages[-1], class_name) # Load the test cases and return the suite of test cases. - return unittest.TestLoader().loadTestsFromTestCase(clazz) + return TestLoader().loadTestsFromTestCase(clazz)