Current File : //usr/lib/python3.6/site-packages/bs4/tests/__pycache__/test_html5lib.cpython-36.pyc |
3
6]+ � @ s� d Z ddlZyddlmZ dZW n& ek
rF Z z
dZW Y ddZ[X nX ddlmZ ddl m
Z
mZmZ ee d�G d d
� d
ee
��Z
dS )zDTests to ensure that the html5lib tree builder generates good trees.� N)�HTML5TreeBuilderTF)�SoupStrainer)�HTML5TreeBuilderSmokeTest�SoupTest�skipIfz?html5lib seems not to be present, not testing its tree builder.c @ sl e Zd ZdZedd� �Zdd� Zdd� Zdd � Zd
d� Z dd
� Z
dd� Zdd� Zdd� Z
dd� Zdd� ZdS )�HTML5LibBuilderSmokeTestz"See ``HTML5TreeBuilderSmokeTest``.c C s t � S )N)r )�self� r �#/usr/lib/python3.6/test_html5lib.py�default_builder s z(HTML5LibBuilderSmokeTest.default_builderc C sd t d�}d}tjdd��}| j||d�}W d Q R X | j|j� | j|�� | jdt|d j �k� d S )N�bz<p>A <b>bold</b> statement.</p>T)�record)Z
parse_onlyz4the html5lib tree builder doesn't support parse_onlyr )
r �warnings�catch_warnings�soup�assertEqual�decodeZdocument_forZ
assertTrue�str�message)r Zstrainer�markup�wr r r r
�test_soupstrainer s z*HTML5LibBuilderSmokeTest.test_soupstrainerc C s d}| j |d� | j d� dS )z8html5lib inserts <tbody> tags where other parsers don't.z[<table id="1"><tr><td>Here's another table:<table id="2"><tr><td>foo</td></tr></table></td>z�<table id="1"><tbody><tr><td>Here's another table:<table id="2"><tbody><tr><td>foo</td></tr></tbody></table></td></tr></tbody></table>z{<table><thead><tr><td>Foo</td></tr></thead><tbody><tr><td>Bar</td></tr></tbody><tfoot><tr><td>Baz</td></tr></tfoot></table>N)ZassertSoupEquals)r r r r r
�test_correctly_nested_tables( s z5HTML5LibBuilderSmokeTest.test_correctly_nested_tablesc C s$ d}| j |�}| jd|jj� � d S )Nzy<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>foo</p>
</body>
</html>s
<p>foo</p>)r r �p�encode)r r r r r r
�(test_xml_declaration_followed_by_doctype<