@pytest.mark.parametrize('redirect', [True, False])
def test_adding_item_during_async_read(qtbot, hist, redirect):
 url = QUrl('http://www.example.com/')
 with qtbot.assertNotEmitted(hist.add_completion_item):
  with qtbot.assertNotEmitted(hist.item_added):
   hist.add_url(url, redirect=redirect, atime=12345)
 if redirect:
  with qtbot.assertNotEmitted(hist.add_completion_item):
   with qtbot.waitSignal(hist.async_read_done):
    list(hist.async_read())
 else:
  with qtbot.waitSignals([hist.add_completion_item, hist.async_read_done], order='strict'):
   list(hist.async_read())
 assert (not hist._temp_history)
 expected = history.Entry(url=url, atime=12345, redirect=redirect, title='')
 assert (list(hist.history_dict.values()) == [expected])

@ pytest . mark . parametrize ( 'redirect' , [ True , False ] ) def test_adding_item_during_async_read ( qtbot , hist , redirect ) : url = QUrl ( 'http://www.example.com/' ) with qtbot . assertNotEmitted ( hist . add_completion_item ) : with qtbot . assertNotEmitted ( hist . item_added ) : hist . add_url ( url , redirect = redirect , atime = 12345 ) if redirect : with qtbot . assertNotEmitted ( hist . add_completion_item ) : with qtbot . waitSignal ( hist . async_read_done ) : list ( hist . async_read ( ) ) else : with qtbot . waitSignals ( [ hist . add_completion_item , hist . async_read_done ] , order = 'strict' ) : list ( hist . async_read ( ) ) assert ( not hist . _temp_history ) expected = history . Entry ( url = url , atime = 12345 , redirect = redirect , title = '' ) assert ( list ( hist . history_dict . values ( ) ) == [ expected ] )
check what happens when adding url while reading the history .