def test_refresh_called_twice(refresher):
 callbacks = Mock()
 pgexecute = Mock()
 special = Mock()
 def dummy_bg_refresh(*args):
  time.sleep(3)
 refresher._bg_refresh = dummy_bg_refresh
 actual1 = refresher.refresh(pgexecute, special, callbacks)
 time.sleep(1)
 assert (len(actual1) == 1)
 assert (len(actual1[0]) == 4)
 assert (actual1[0][3] == 'Auto-completion refresh started in the background.')
 actual2 = refresher.refresh(pgexecute, special, callbacks)
 time.sleep(1)
 assert (len(actual2) == 1)
 assert (len(actual2[0]) == 4)
 assert (actual2[0][3] == 'Auto-completion refresh restarted.')

def test_refresh_called_twice ( refresher ) : callbacks = Mock ( ) pgexecute = Mock ( ) special = Mock ( ) def dummy_bg_refresh ( * args ) : time . sleep ( 3 ) refresher . _bg_refresh = dummy_bg_refresh actual1 = refresher . refresh ( pgexecute , special , callbacks ) time . sleep ( 1 ) assert ( len ( actual1 ) == 1 ) assert ( len ( actual1 [ 0 ] ) == 4 ) assert ( actual1 [ 0 ] [ 3 ] == 'Auto-completion refresh started in the background.' ) actual2 = refresher . refresh ( pgexecute , special , callbacks ) time . sleep ( 1 ) assert ( len ( actual2 ) == 1 ) assert ( len ( actual2 [ 0 ] ) == 4 ) assert ( actual2 [ 0 ] [ 3 ] == 'Auto-completion refresh restarted.' )
if refresh is called a second time .