PyUnit/UnittestDialog.py

branch
Py2 comp.
changeset 2525
8b507a9a2d40
parent 2409
df3820f08247
child 2791
a9577f248f04
equal deleted inserted replaced
2523:139f182b72f6 2525:8b507a9a2d40
4 # 4 #
5 5
6 """ 6 """
7 Module implementing the UI to the pyunit package. 7 Module implementing the UI to the pyunit package.
8 """ 8 """
9
10 from __future__ import unicode_literals # __IGNORE_WARNING__
9 11
10 import unittest 12 import unittest
11 import sys 13 import sys
12 import time 14 import time
13 import re 15 import re
52 @param fromEric flag indicating an instantiation from within the 54 @param fromEric flag indicating an instantiation from within the
53 eric IDE (boolean) 55 eric IDE (boolean)
54 @param parent parent widget of this dialog (QWidget) 56 @param parent parent widget of this dialog (QWidget)
55 @param name name of this dialog (string) 57 @param name name of this dialog (string)
56 """ 58 """
57 super().__init__(parent) 59 super(UnittestDialog, self).__init__(parent)
58 if name: 60 if name:
59 self.setObjectName(name) 61 self.setObjectName(name)
60 self.setupUi(self) 62 self.setupUi(self)
61 63
62 self.startButton = self.buttonBox.addButton( 64 self.startButton = self.buttonBox.addButton(
653 """ 655 """
654 Constructor 656 Constructor
655 657
656 @param parent The parent widget. 658 @param parent The parent widget.
657 """ 659 """
658 super().__init__() 660 super(QtTestResult, self).__init__()
659 self.parent = parent 661 self.parent = parent
660 662
661 def addFailure(self, test, err): 663 def addFailure(self, test, err):
662 """ 664 """
663 Method called if a test failed. 665 Method called if a test failed.
664 666
665 @param test reference to the test object 667 @param test reference to the test object
666 @param err error traceback 668 @param err error traceback
667 """ 669 """
668 super().addFailure(test, err) 670 super(QtTestResult, self).addFailure(test, err)
669 tracebackLines = self._exc_info_to_string(err, test) 671 tracebackLines = self._exc_info_to_string(err, test)
670 self.parent.testFailed(str(test), tracebackLines, test.id()) 672 self.parent.testFailed(str(test), tracebackLines, test.id())
671 673
672 def addError(self, test, err): 674 def addError(self, test, err):
673 """ 675 """
674 Method called if a test errored. 676 Method called if a test errored.
675 677
676 @param test reference to the test object 678 @param test reference to the test object
677 @param err error traceback 679 @param err error traceback
678 """ 680 """
679 super().addError(test, err) 681 super(QtTestResult, self).addError(test, err)
680 tracebackLines = self._exc_info_to_string(err, test) 682 tracebackLines = self._exc_info_to_string(err, test)
681 self.parent.testErrored(str(test), tracebackLines, test.id()) 683 self.parent.testErrored(str(test), tracebackLines, test.id())
682 684
683 def addSkip(self, test, reason): 685 def addSkip(self, test, reason):
684 """ 686 """
685 Method called if a test was skipped. 687 Method called if a test was skipped.
686 688
687 @param test reference to the test object 689 @param test reference to the test object
688 @param reason reason for skipping the test (string) 690 @param reason reason for skipping the test (string)
689 """ 691 """
690 super().addSkip(test, reason) 692 super(QtTestResult, self).addSkip(test, reason)
691 self.parent.testSkipped(str(test), reason, test.id()) 693 self.parent.testSkipped(str(test), reason, test.id())
692 694
693 def addExpectedFailure(self, test, err): 695 def addExpectedFailure(self, test, err):
694 """ 696 """
695 Method called if a test failed expected. 697 Method called if a test failed expected.
696 698
697 @param test reference to the test object 699 @param test reference to the test object
698 @param err error traceback 700 @param err error traceback
699 """ 701 """
700 super().addExpectedFailure(test, err) 702 super(QtTestResult, self).addExpectedFailure(test, err)
701 tracebackLines = self._exc_info_to_string(err, test) 703 tracebackLines = self._exc_info_to_string(err, test)
702 self.parent.testFailedExpected(str(test), tracebackLines, test.id()) 704 self.parent.testFailedExpected(str(test), tracebackLines, test.id())
703 705
704 def addUnexpectedSuccess(self, test): 706 def addUnexpectedSuccess(self, test):
705 """ 707 """
706 Method called if a test succeeded expectedly. 708 Method called if a test succeeded expectedly.
707 709
708 @param test reference to the test object 710 @param test reference to the test object
709 """ 711 """
710 super().addUnexpectedSuccess(test) 712 super(QtTestResult, self).addUnexpectedSuccess(test)
711 self.parent.testSucceededUnexpected(str(test), test.id()) 713 self.parent.testSucceededUnexpected(str(test), test.id())
712 714
713 def startTest(self, test): 715 def startTest(self, test):
714 """ 716 """
715 Method called at the start of a test. 717 Method called at the start of a test.
716 718
717 @param test Reference to the test object 719 @param test Reference to the test object
718 """ 720 """
719 super().startTest(test) 721 super(QtTestResult, self).startTest(test)
720 self.parent.testStarted(str(test), test.shortDescription()) 722 self.parent.testStarted(str(test), test.shortDescription())
721 723
722 def stopTest(self, test): 724 def stopTest(self, test):
723 """ 725 """
724 Method called at the end of a test. 726 Method called at the end of a test.
725 727
726 @param test Reference to the test object 728 @param test Reference to the test object
727 """ 729 """
728 super().stopTest(test) 730 super(QtTestResult, self).stopTest(test)
729 self.parent.testFinished() 731 self.parent.testFinished()
730 732
731 733
732 class UnittestWindow(E5MainWindow): 734 class UnittestWindow(E5MainWindow):
733 """ 735 """
738 Constructor 740 Constructor
739 741
740 @param prog filename of the program to open 742 @param prog filename of the program to open
741 @param parent reference to the parent widget (QWidget) 743 @param parent reference to the parent widget (QWidget)
742 """ 744 """
743 super().__init__(parent) 745 super(UnittestWindow, self).__init__(parent)
744 self.cw = UnittestDialog(prog=prog, parent=self) 746 self.cw = UnittestDialog(prog=prog, parent=self)
745 self.cw.installEventFilter(self) 747 self.cw.installEventFilter(self)
746 size = self.cw.size() 748 size = self.cw.size()
747 self.setCentralWidget(self.cw) 749 self.setCentralWidget(self.cw)
748 self.resize(size) 750 self.resize(size)

eric ide

mercurial