# eric4.PyUnit.UnittestDialog

Module implementing the UI to the pyunit package.

### Classes

QtTestResult | A TestResult derivative to work with a graphical GUI.
UnittestDialog | Class implementing the UI to the pyunit package.
UnittestWindow | Main window class for the standalone dialog.

### Functions

None

## QtTestResult

A TestResult derivative to work with a graphical GUI.

For more details see pyunit.py of the standard python distribution.

### Derived from

unittest.TestResult

### Methods

QtTestResult | Constructor
addError | Method called if a test errored.
addFailure | Method called if a test failed.
startTest | Method called at the start of a test.
stopTest | Method called at the end of a test.

#### QtTestResult (Constructor)

QtTestResult(parent)

Constructor

parent
  The parent widget.

#### QtTestResult.addError

addError(test, err)

Method called if a test errored.

test
  Reference to the test object
err
  The error traceback

#### QtTestResult.addFailure

addFailure(test, err)

Method called if a test failed.

test
  Reference to the test object
err
  The error traceback

#### QtTestResult.startTest

startTest(test)

Method called at the start of a test.

test
  Reference to the test object

#### QtTestResult.stopTest

stopTest(test)

Method called at the end of a test.

test
  Reference to the test object

Up

## UnittestDialog

Class implementing the UI to the pyunit package.

#### Signals

unittestFile(string,int,int)
  emitted to show the source of a unittest file

### Derived from

QWidget, Ui_UnittestDialog

### Methods

UnittestDialog | Constructor
__UTPrepared | Private slot to handle the utPrepared signal.
__setProgressColor | Private methode to set the color of the progress color label.
__setRunningMode | Private method to set the GUI in running mode.
__setStoppedMode | Private method to set the GUI in stopped mode.
__showSource | Private slot to show the source of a traceback in an eric4 editor.
insertProg | Public slot to insert the filename prog into the testsuiteComboBox object.
insertTestName | Public slot to insert a test name into the testComboBox object.
on_buttonBox_clicked | Private slot called by a button of the button box clicked.
on_errorsListWidget_currentTextChanged | Private slot to handle the highlighted(const QString&) signal.
on_errorsListWidget_itemDoubleClicked | Private slot called by doubleclicking an errorlist entry.
on_fileDialogButton_clicked | Private slot to open a file dialog.
on_startButton_clicked | Public slot to start the test.
on_stopButton_clicked | Private slot to stop the test.
testErrored | Public method called if a test errors.
testFailed | Public method called if a test fails.
testFinished | Public method called if a test has finished.
testStarted | Public method called if a test is about to be run.

#### UnittestDialog (Constructor)

UnittestDialog(prog = None, dbs = None, ui = None, parent = None, name = None)

Constructor

prog
  filename of the program to open
dbs
  reference to the debug server object. It is an indication whether we were called from within the eric4 IDE
ui
  reference to the UI object
parent
  parent widget of this dialog (QWidget)
name
  name of this dialog (string or QString)

#### UnittestDialog.__UTPrepared

__UTPrepared(nrTests, exc_type, exc_value)

Private slot to handle the utPrepared signal.

If the unittest suite was loaded successfully, we ask the client to run the test suite.

nrTests
  number of tests contained in the test suite (integer)
exc_type
  type of exception occured during preparation (string)
exc_value
  value of exception occured during preparation (string)

#### UnittestDialog.__setProgressColor

__setProgressColor(color)

Private methode to set the color of the progress color label.

color
  colour to be shown

#### UnittestDialog.__setRunningMode

__setRunningMode()

Private method to set the GUI in running mode.

#### UnittestDialog.__setStoppedMode

__setStoppedMode()

Private method to set the GUI in stopped mode.

#### UnittestDialog.__showSource

__showSource()

Private slot to show the source of a traceback in an eric4 editor.

#### UnittestDialog.insertProg

insertProg(prog)

Public slot to insert the filename prog into the testsuiteComboBox object.

prog
  filename to be inserted (string or QString)

#### UnittestDialog.insertTestName

insertTestName(testName)

Public slot to insert a test name into the testComboBox object.

testName
  name of the test to be inserted (string or QString)

#### UnittestDialog.on_buttonBox_clicked

on_buttonBox_clicked(button)

Private slot called by a button of the button box clicked.

button
  button that was clicked (QAbstractButton)

#### UnittestDialog.on_errorsListWidget_currentTextChanged

on_errorsListWidget_currentTextChanged(text)

Private slot to handle the highlighted(const QString&) signal.

#### UnittestDialog.on_errorsListWidget_itemDoubleClicked

on_errorsListWidget_itemDoubleClicked(lbitem)

Private slot called by doubleclicking an errorlist entry.

It will popup a dialog showing the stacktrace. If called from eric, an additional button is displayed to show the python source in an eric source viewer (in erics main window.

lbitem
  the listbox item that was double clicked

#### UnittestDialog.on_fileDialogButton_clicked

on_fileDialogButton_clicked()

Private slot to open a file dialog.

#### UnittestDialog.on_startButton_clicked

on_startButton_clicked()

Public slot to start the test.

#### UnittestDialog.on_stopButton_clicked

on_stopButton_clicked()

Private slot to stop the test.

#### UnittestDialog.testErrored

testErrored(test, exc)

Public method called if a test errors.

test
  name of the failed test (string)
exc
  string representation of the exception (list of strings)

#### UnittestDialog.testFailed

testFailed(test, exc)

Public method called if a test fails.

test
  name of the failed test (string)
exc
  string representation of the exception (list of strings)

#### UnittestDialog.testFinished

testFinished()

Public method called if a test has finished.

Note: It is also called if it has already failed or errored.

#### UnittestDialog.testStarted

testStarted(test, doc)

Public method called if a test is about to be run.

test
  name of the started test (string)
doc
  documentation of the started test (string)

Up

## UnittestWindow

Main window class for the standalone dialog.

### Derived from

KQMainWindow

### Methods

UnittestWindow | Constructor
eventFilter | Public method to filter events.

#### UnittestWindow (Constructor)

UnittestWindow(prog = None, parent = None)

Constructor

prog
  filename of the program to open
parent
  reference to the parent widget (QWidget)

#### UnittestWindow.eventFilter

eventFilter(obj, event)

Public method to filter events.

obj
  reference to the object the event is meant for (QObject)
event
  reference to the event object (QEvent)

Returns:
  flag indicating, whether the event was handled (boolean)

Up