Author: bugman Date: Tue Aug 6 10:23:46 2013 New Revision: 20542 URL: http://svn.gna.org/viewcvs/relax?rev=20542&view=rev Log: An attempt at better handling MS Windows not releasing the file handle on time in the test suite. The system and unit tests tearDown() method should now be resilient to the strange MS Windows behaviour of not releasing the relax state files. The tearDown() method should now complete even when this error occurs. A delay of 3 seconds has been added when the WindowsError occurs to give the OS some time before attempting to delete the file again. If this fails, then the file deletion operation is skipped. Modified: trunk/test_suite/system_tests/base_classes.py trunk/test_suite/unit_tests/base_classes.py Modified: trunk/test_suite/system_tests/base_classes.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/system_tests/base_classes.py?rev=20542&r1=20541&r2=20542&view=diff ============================================================================== --- trunk/test_suite/system_tests/base_classes.py (original) +++ trunk/test_suite/system_tests/base_classes.py Tue Aug 6 10:23:46 2013 @@ -67,40 +67,43 @@ def tearDown(self): """Default tearDown operation - delete temp directories and files and reset relax.""" - # Horrible MS Windows kludge - avoid the WindowsError due to the file still being open by the state.save or results.write user functions. - sleep(0.03) - - # Remove the temporary directories. + # Remove the temporary directory and variable. if hasattr(ds, 'tmpdir'): - # Delete the directory. rmtree(ds.tmpdir) - - # Remove the variable. del ds.tmpdir - # Remove the temporary directories. + # Remove the temporary directory and variable. if hasattr(self, 'tmpdir'): - # Delete the directory. rmtree(self.tmpdir) - - # Remove the variable. del self.tmpdir - # Remove temporary files. + # Remove temporary file and variable. if hasattr(ds, 'tmpfile'): - # Delete the file. - delete(ds.tmpfile, fail=False) + try: + delete(ds.tmpfile, fail=False) + del ds.tmpfile - # Remove the variable. - del ds.tmpfile + # Handle MS Windows strangeness. + except WindowsError: + sleep(3) + try: + delete(ds.tmpfile, fail=False) + finally: + del ds.tmpfile - # Remove temporary files. + # Remove temporary file and variable. if hasattr(self, 'tmpfile'): - # Delete the file. - delete(self.tmpfile, fail=False) + try: + delete(self.tmpfile, fail=False) + del self.tmpfile - # Remove the variable. - del self.tmpfile + # Handle MS Windows strangeness. + except WindowsError: + sleep(3) + try: + delete(ds.tmpfile, fail=False) + finally: + del ds.tmpfile # Reset relax. reset() Modified: trunk/test_suite/unit_tests/base_classes.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/base_classes.py?rev=20542&r1=20541&r2=20542&view=diff ============================================================================== --- trunk/test_suite/unit_tests/base_classes.py (original) +++ trunk/test_suite/unit_tests/base_classes.py Tue Aug 6 10:23:46 2013 @@ -24,6 +24,7 @@ # Python module imports. from shutil import rmtree +from time import sleep from unittest import TestCase # relax module imports. @@ -38,37 +39,43 @@ def tearDown(self): """Default tearDown operation - delete temp directories and files and reset relax.""" - # Remove the temporary directories. + # Remove the temporary directory and variable. if hasattr(ds, 'tmpdir'): - # Delete the directory. rmtree(ds.tmpdir) - - # Remove the variable. del ds.tmpdir - # Remove the temporary directories. + # Remove the temporary directory and variable. if hasattr(self, 'tmpdir'): - # Delete the directory. rmtree(self.tmpdir) - - # Remove the variable. del self.tmpdir - # Remove temporary files. + # Remove temporary file and variable. if hasattr(ds, 'tmpfile'): - # Delete the file. - delete(ds.tmpfile, fail=False) + try: + delete(ds.tmpfile, fail=False) + del ds.tmpfile - # Remove the variable. - del ds.tmpfile + # Handle MS Windows strangeness. + except WindowsError: + sleep(3) + try: + delete(ds.tmpfile, fail=False) + finally: + del ds.tmpfile - # Remove temporary files. + # Remove temporary file and variable. if hasattr(self, 'tmpfile'): - # Delete the file. - delete(self.tmpfile, fail=False) + try: + delete(self.tmpfile, fail=False) + del self.tmpfile - # Remove the variable. - del self.tmpfile + # Handle MS Windows strangeness. + except WindowsError: + sleep(3) + try: + delete(ds.tmpfile, fail=False) + finally: + del ds.tmpfile # Reset relax. reset()