610 |
610 |
611 try: |
611 try: |
612 code = self.compile_command(self.buffer, self.readstream.name) |
612 code = self.compile_command(self.buffer, self.readstream.name) |
613 except (OverflowError, SyntaxError, ValueError): |
613 except (OverflowError, SyntaxError, ValueError): |
614 # Report the exception |
614 # Report the exception |
615 sys.last_type, sys.last_value, sys.last_traceback = \ |
615 sys.last_type, sys.last_value, sys.last_traceback = ( |
616 sys.exc_info() |
616 sys.exc_info()) |
617 self.sendJsonCommand("ClientOutput", { |
617 self.sendJsonCommand("ClientOutput", { |
618 "text": "".join(traceback.format_exception_only( |
618 "text": "".join(traceback.format_exception_only( |
619 sys.last_type, sys.last_value)) |
619 sys.last_type, sys.last_value)) |
620 }) |
620 }) |
621 self.buffer = '' |
621 self.buffer = '' |
646 frmnr = self.framenr |
646 frmnr = self.framenr |
647 while cf is not None and frmnr > 0: |
647 while cf is not None and frmnr > 0: |
648 cf = cf.f_back |
648 cf = cf.f_back |
649 frmnr -= 1 |
649 frmnr -= 1 |
650 _globals = cf.f_globals |
650 _globals = cf.f_globals |
651 _locals = \ |
651 _locals = ( |
652 self.currentThread.getFrameLocals( |
652 self.currentThread.getFrameLocals( |
653 self.framenr) |
653 self.framenr)) |
654 ## reset sys.stdout to our redirector |
654 ## reset sys.stdout to our redirector |
655 ## (unconditionally) |
655 ## (unconditionally) |
656 if "sys" in _globals: |
656 if "sys" in _globals: |
657 __stdout = _globals["sys"].stdout |
657 __stdout = _globals["sys"].stdout |
658 _globals["sys"].stdout = self.writestream |
658 _globals["sys"].stdout = self.writestream |
823 try: |
823 try: |
824 import unittest |
824 import unittest |
825 testLoader = unittest.TestLoader() |
825 testLoader = unittest.TestLoader() |
826 test = testLoader.discover( |
826 test = testLoader.discover( |
827 discoveryStart, top_level_dir=top_level_dir) |
827 discoveryStart, top_level_dir=top_level_dir) |
828 if hasattr(testLoader, "errors") and \ |
828 if (hasattr(testLoader, "errors") and |
829 bool(testLoader.errors): |
829 bool(testLoader.errors)): |
830 self.sendJsonCommand("ResponseUTDiscover", { |
830 self.sendJsonCommand("ResponseUTDiscover", { |
831 "testCasesList": [], |
831 "testCasesList": [], |
832 "exception": "DiscoveryError", |
832 "exception": "DiscoveryError", |
833 "message": "\n\n".join(testLoader.errors), |
833 "message": "\n\n".join(testLoader.errors), |
834 }) |
834 }) |
976 for test in suite: |
976 for test in suite: |
977 if isinstance(test, unittest.TestSuite): |
977 if isinstance(test, unittest.TestSuite): |
978 testCases.extend(self.__assembleTestCasesList(test, start)) |
978 testCases.extend(self.__assembleTestCasesList(test, start)) |
979 else: |
979 else: |
980 testId = test.id() |
980 testId = test.id() |
981 if "ModuleImportFailure" not in testId and \ |
981 if ("ModuleImportFailure" not in testId and |
982 "LoadTestsFailure" not in testId and \ |
982 "LoadTestsFailure" not in testId and |
983 "_FailedTest" not in testId: |
983 "_FailedTest" not in testId): |
984 filename = os.path.join( |
984 filename = os.path.join( |
985 start, |
985 start, |
986 test.__module__.replace(".", os.sep) + ".py") |
986 test.__module__.replace(".", os.sep) + ".py") |
987 testCases.append( |
987 testCases.append( |
988 (test.id(), test.shortDescription(), filename) |
988 (test.id(), test.shortDescription(), filename) |