# eric6.PyUnit.UnittestDialog

Module implementing the UI to the pyunit package.

### Global Attributes

None

### 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

### Class Attributes

None

### Class Methods

None

### Methods

QtTestResult | Constructor
addError | Public method called if a test errored.
addExpectedFailure | Public method called if a test failed expected.
addFailure | Public method called if a test failed.
addSkip | Public method called if a test was skipped.
addUnexpectedSuccess | Public method called if a test succeeded expectedly.
startTest | Public method called at the start of a test.
stopTest | Public method called at the end of a test.

### Static Methods

None

#### QtTestResult (Constructor)

QtTestResult(parent)

Constructor

parent
  The parent widget.

#### QtTestResult.addError

addError(test, err)

Public method called if a test errored.

test
  reference to the test object
err
  error traceback

#### QtTestResult.addExpectedFailure

addExpectedFailure(test, err)

Public method called if a test failed expected.

test
  reference to the test object
err
  error traceback

#### QtTestResult.addFailure

addFailure(test, err)

Public method called if a test failed.

test
  reference to the test object
err
  error traceback

#### QtTestResult.addSkip

addSkip(test, reason)

Public method called if a test was skipped.

test
  reference to the test object
reason
  reason for skipping the test (string)

#### QtTestResult.addUnexpectedSuccess

addUnexpectedSuccess(test)

Public method called if a test succeeded expectedly.

test
  reference to the test object

#### QtTestResult.startTest

startTest(test)

Public method called at the start of a test.

test
  Reference to the test object

#### QtTestResult.stopTest

stopTest(test)

Public 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(str, int, int)
  emitted to show the source of a unittest file
unittestStopped()
  emitted after a unit test was run

### Derived from

QWidget, Ui_UnittestDialog

### Class Attributes

None

### Class Methods

None

### 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 eric6 editor.
hasFailedTests | Public method to check, if there are failed tests from the last run.
insertProg | Public slot to insert the filename prog into the testsuiteComboBox object.
insertTestName | Public slot to insert a test name into the testComboBox object.
keyPressEvent | Protected slot to handle key press events.
on_buttonBox_clicked | Private slot called by a button of the button box clicked.
on_errorsListWidget_currentTextChanged | Private slot to handle the highlighted 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 | Private slot to start the test.
on_stopButton_clicked | Private slot to stop the test.
on_testsuiteComboBox_editTextChanged | Private slot to handle changes of the test file name.
testErrored | Public method called if a test errors.
testFailed | Public method called if a test fails.
testFailedExpected | Public method called if a test fails expectedly.
testFinished | Public method called if a test has finished.
testSkipped | Public method called if a test was skipped.
testStarted | Public method called if a test is about to be run.
testSucceededUnexpected | Public method called if a test succeeds unexpectedly.

### Static Methods

None

#### UnittestDialog (Constructor)

UnittestDialog(prog=None, dbs=None, ui=None, fromEric=False, 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 eric6 IDE
ui
  reference to the UI object
fromEric
  flag indicating an instantiation from within the eric IDE (boolean)
parent
  parent widget of this dialog (QWidget)
name
  name of this dialog (string)

#### 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 (string)

#### 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 eric6 editor.

#### UnittestDialog.hasFailedTests

hasFailedTests()

Public method to check, if there are failed tests from the last run.

Returns:
  flag indicating the presence of failed tests (boolean)

#### UnittestDialog.insertProg

insertProg(prog)

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

prog
  filename to be inserted (string)

#### UnittestDialog.insertTestName

insertTestName(testName)

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

testName
  name of the test to be inserted (string)

#### UnittestDialog.keyPressEvent

keyPressEvent(evt)

Protected slot to handle key press events.

evt
  key press event to handle (QKeyEvent)

#### 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 signal.

text
  current text (string)

#### 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(failedOnly=False)

Private slot to start the test.

failedOnly=
  flag indicating to run only failed tests (boolean)

#### UnittestDialog.on_stopButton_clicked

on_stopButton_clicked()

Private slot to stop the test.

#### UnittestDialog.on_testsuiteComboBox_editTextChanged

on_testsuiteComboBox_editTextChanged(txt)

Private slot to handle changes of the test file name.

txt
  name of the test file (string)

#### UnittestDialog.testErrored

testErrored(test, exc, id)

Public method called if a test errors.

test
  name of the test (string)
exc
  string representation of the exception (string)
id
  id of the test (string)

#### UnittestDialog.testFailed

testFailed(test, exc, id)

Public method called if a test fails.

test
  name of the test (string)
exc
  string representation of the exception (string)
id
  id of the test (string)

#### UnittestDialog.testFailedExpected

testFailedExpected(test, exc, id)

Public method called if a test fails expectedly.

test
  name of the test (string)
exc
  string representation of the exception (string)
id
  id of the test (string)

#### UnittestDialog.testFinished

testFinished()

Public method called if a test has finished.

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

#### UnittestDialog.testSkipped

testSkipped(test, reason, id)

Public method called if a test was skipped.

test
  name of the test (string)
reason
  reason for skipping the test (string)
id
  id of the test (string)

#### 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)

#### UnittestDialog.testSucceededUnexpected

testSucceededUnexpected(test, id)

Public method called if a test succeeds unexpectedly.

test
  name of the test (string)
id
  id of the test (string)

Up

## UnittestWindow

Main window class for the standalone dialog.

### Derived from

E5MainWindow

### Class Attributes

None

### Class Methods

None

### Methods

UnittestWindow | Constructor
eventFilter | Public method to filter events.

### Static Methods

None

#### 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