def test_patched_errwindow(capfd, mocker, monkeypatch):
 monkeypatch.setattr('qutebrowser.misc.checkpyver.sys.hexversion', 50331648)
 monkeypatch.setattr('qutebrowser.misc.checkpyver.sys.exit', (lambda status: None))
 try:
  import tkinter
 except ImportError:
  tk_mock = mocker.patch('qutebrowser.misc.checkpyver.Tk', spec=['withdraw'], new_callable=mocker.Mock)
  msgbox_mock = mocker.patch('qutebrowser.misc.checkpyver.messagebox', spec=['showerror'])
 else:
  tk_mock = mocker.patch('qutebrowser.misc.checkpyver.Tk', autospec=True)
  msgbox_mock = mocker.patch('qutebrowser.misc.checkpyver.messagebox', autospec=True)
 checkpyver.check_python_version()
 (stdout, stderr) = capfd.readouterr()
 assert (not stdout)
 assert (not stderr)
 tk_mock.assert_called_with()
 tk_mock().withdraw.assert_called_with()
 msgbox_mock.showerror.assert_called_with('qutebrowser: Fatal error!', unittest.mock.ANY)

def test_patched_errwindow ( capfd , mocker , monkeypatch ) : monkeypatch . setattr ( 'qutebrowser.misc.checkpyver.sys.hexversion' , 50331648 ) monkeypatch . setattr ( 'qutebrowser.misc.checkpyver.sys.exit' , ( lambda status : None ) ) try : import tkinter except ImportError : tk_mock = mocker . patch ( 'qutebrowser.misc.checkpyver.Tk' , spec = [ 'withdraw' ] , new_callable = mocker . Mock ) msgbox_mock = mocker . patch ( 'qutebrowser.misc.checkpyver.messagebox' , spec = [ 'showerror' ] ) else : tk_mock = mocker . patch ( 'qutebrowser.misc.checkpyver.Tk' , autospec = True ) msgbox_mock = mocker . patch ( 'qutebrowser.misc.checkpyver.messagebox' , autospec = True ) checkpyver . check_python_version ( ) ( stdout , stderr ) = capfd . readouterr ( ) assert ( not stdout ) assert ( not stderr ) tk_mock . assert_called_with ( ) tk_mock ( ) . withdraw . assert_called_with ( ) msgbox_mock . showerror . assert_called_with ( 'qutebrowser: Fatal error!' , unittest . mock . ANY )
test with a patched sys .