@bdd.then(bdd.parsers.parse('the following tabs should be open:\n{tabs}'))
def check_open_tabs(quteproc, request, tabs):
 session = quteproc.get_session()
 active_suffix = ' (active)'
 tabs = tabs.splitlines()
 assert (len(session['windows']) == 1)
 assert (len(session['windows'][0]['tabs']) == len(tabs))
 for (i, line) in enumerate(tabs):
  line = line.strip()
  assert line.startswith('- ')
  line = line[2:]
  if line.endswith(active_suffix):
   path = line[:(- len(active_suffix))]
   active = True
  else:
   path = line
   active = False
  session_tab = session['windows'][0]['tabs'][i]
  assert (session_tab['history'][(-1)]['url'] == quteproc.path_to_url(path))
  if active:
   assert session_tab['active']
  else:
   assert ('active' not in session_tab)

@ bdd . then ( bdd . parsers . parse ( 'the following tabs should be open:\n{tabs}' ) ) def check_open_tabs ( quteproc , request , tabs ) : session = quteproc . get_session ( ) active_suffix = ' (active)' tabs = tabs . splitlines ( ) assert ( len ( session [ 'windows' ] ) == 1 ) assert ( len ( session [ 'windows' ] [ 0 ] [ 'tabs' ] ) == len ( tabs ) ) for ( i , line ) in enumerate ( tabs ) : line = line . strip ( ) assert line . startswith ( '- ' ) line = line [ 2 : ] if line . endswith ( active_suffix ) : path = line [ : ( - len ( active_suffix ) ) ] active = True else : path = line active = False session_tab = session [ 'windows' ] [ 0 ] [ 'tabs' ] [ i ] assert ( session_tab [ 'history' ] [ ( - 1 ) ] [ 'url' ] == quteproc . path_to_url ( path ) ) if active : assert session_tab [ 'active' ] else : assert ( 'active' not in session_tab )
check the list of open tabs in the session .