@pytest.mark.skipif('not HAS_BEAUTIFUL_SOUP')
def test_htmlsplitter():
 splitter = html.HTMLSplitter()
 lines = [html.SoupString(BeautifulSoup('<table><tr><th>Col 1</th><th>Col 2</th></tr></table>').tr), html.SoupString(BeautifulSoup('<table><tr><td>Data 1</td><td>Data 2</td></tr></table>').tr)]
 expected_data = [['Col 1', 'Col 2'], ['Data 1', 'Data 2']]
 assert (list(splitter(lines)) == expected_data)
 lines.append('<tr><td>Data 3</td><td>Data 4</td></tr>')
 with pytest.raises(TypeError):
  list(splitter(lines))
 with pytest.raises(core.InconsistentTableError):
  list(splitter([]))

@ pytest . mark . skipif ( 'not HAS_BEAUTIFUL_SOUP' ) def test_htmlsplitter ( ) : splitter = html . HTMLSplitter ( ) lines = [ html . SoupString ( BeautifulSoup ( '<table><tr><th>Col 1</th><th>Col 2</th></tr></table>' ) . tr ) , html . SoupString ( BeautifulSoup ( '<table><tr><td>Data 1</td><td>Data 2</td></tr></table>' ) . tr ) ] expected_data = [ [ 'Col 1' , 'Col 2' ] , [ 'Data 1' , 'Data 2' ] ] assert ( list ( splitter ( lines ) ) == expected_data ) lines . append ( '<tr><td>Data 3</td><td>Data 4</td></tr>' ) with pytest . raises ( TypeError ) : list ( splitter ( lines ) ) with pytest . raises ( core . InconsistentTableError ) : list ( splitter ( [ ] ) )
test to make sure that htmlsplitter correctly inputs lines of type soupstring to return a generator that gives all header and data elements .