def METHOD_NAME(self):
    w = AddonManagerDialog()
    foo = Available(Installable("foo", "1.1", "", "", "", []))
    w.setItems([foo])
    w.setItemState([(Install, foo)])
    with patch.object(PipInstaller, "install", lambda self, pkg: None), \
         patch.object(CondaInstaller, "install", lambda self, pkg: None), \
         patch.object(QMessageBox, "exec", return_value=QMessageBox.Cancel):
        b = w.findChild(QDialogButtonBox)
        b.accepted.emit()
        QTest.qWait(1)
        w.reject()
        QTest.qWait(1)
    w.deleteLater()