diff testcases.py @ 136:ed4035661b85

Added a C implementation of the unix module (called _unix)
author Oleg Oshmyan <chortos@inbox.lv>
date Tue, 24 May 2011 20:51:01 +0100
parents e84f33a60a5c
children
line wrap: on
line diff
--- a/testcases.py	Tue May 24 18:59:00 2011 +0100
+++ b/testcases.py	Tue May 24 20:51:01 2011 +0100
@@ -34,10 +34,7 @@
 	def __exit__(self, exc_type, exc_value, traceback): pass
 signal_ignorer = DummySignalIgnorer()
 
-try:
-	from win32 import *
-except Exception:
-	from unix import *
+# win32 and unix are imported a bit later
 
 __all__ = ('TestCase', 'load_problem', 'TestCaseNotPassed',
            'TimeLimitExceeded', 'CanceledByUser', 'WrongAnswer',
@@ -80,6 +77,12 @@
 class CannotReadInputFile(ExceptionWrapper): __slots__ = ()
 class CannotReadAnswerFile(ExceptionWrapper): __slots__ = ()
 
+# Import platform-specific code now that exception classes are defined
+try:
+	from win32 import *
+except Exception:
+	from unix import *
+
 
 
 # Helper context managers
@@ -185,6 +188,8 @@
 			case.cleanup()
 	
 	def cleanup(case):
+		# Note that native extensions clean up on their own
+		# and never let this condition be satisfied
 		if getattr(case, 'process', None) and case.process.returncode is None:
 			kill(case.process)
 		for name in case.files_to_delete: