class Example (QtGui.QWidget): def __init__(self, parent): super(Example, self).__init__(parent) self.mOnverterCay = OnverterCay() self.initUI() def initUI(self): self.xtTay = QtGui.QLineEdit() okButton = QtGui.QPushButton("Onvertcay") self.lbl = QtGui.QLabel('test') okButton.clicked.connect(self.onvertcayText) vbox = QtGui.QVBoxLayout() vbox.addWidget(self.xtTay) vbox.addWidget(self.lbl) vbox.addWidget(okButton) self.setLayout(vbox) #self.setGeometry(10, 10, 300, 150) #self.setWindowTitle('Pig Latinizer') #self.show() def onvertcayText(self): onvertedcayResult = self.mOnverterCay.onvertCay(self.xtTay.text()) self.lbl.setText(onvertedcayResult)
class TestOverterCay(unittest.TestCase): def setUp(self): self.onverterCay = OnverterCay() self.testWord = 'test' self.expectedResult = 'est-tay' def test_onvertCaying(self): result = self.onverterCay.onvertCay(self.testWord) self.assertEqual(self.expectedResult, result, 'oh this ain\'t right...')
def __init__(self, parent): super(Example, self).__init__(parent) self.mOnverterCay = OnverterCay() self.initUI()
def setUp(self): self.onverterCay = OnverterCay() self.testWord = 'test' self.expectedResult = 'est-tay'