Current File : //usr/lib/python3.6/site-packages/bs4/tests/__pycache__/test_html5lib.cpython-36.pyc
3

6]+�@s�dZddlZyddlmZdZWn&ek
rFZz
dZWYddZ[XnXddlmZddl	m
Z
mZmZeed�Gd	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@sleZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�HTML5LibBuilderSmokeTestz"See ``HTML5TreeBuilderSmokeTest``.cCst�S)N)r)�self�r	�#/usr/lib/python3.6/test_html5lib.py�default_buildersz(HTML5LibBuilderSmokeTest.default_buildercCsdtd�}d}tjdd��}|j||d�}WdQRX|j|j�|j|��|jdt|dj	�k�dS)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�decodeZdocument_forZ
assertTrue�str�message)rZstrainer�markup�wrr	r	r
�test_soupstrainersz*HTML5LibBuilderSmokeTest.test_soupstrainercCsd}|j|d�|jd�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)rrr	r	r
�test_correctly_nested_tables(sz5HTML5LibBuilderSmokeTest.test_correctly_nested_tablescCs$d}|j|�}|jd|jj��dS)Nzy<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
   <p>foo</p>
  </body>
</html>s
<p>foo</p>)rr�p�encode)rrrr	r	r
�(test_xml_declaration_followed_by_doctype<s	
zAHTML5LibBuilderSmokeTest.test_xml_declaration_followed_by_doctypecCs:d}|j|�}|jd|jj��|jdt|jd���dS)Nz%<p><em>foo</p>
<p>bar<a></a></em></p>zD<body><p><em>foo</em></p><em>
</em><p><em>bar<a></a></em></p></body>�r)rr�bodyr�len�find_all)rrrr	r	r
�test_reparented_markupJs
z/HTML5LibBuilderSmokeTest.test_reparented_markupcCs:d}|j|�}|jd|jj��|jdt|jd���dS)Nz&<p><em>foo</p>
<p>bar<a></a></em></p>
zE<body><p><em>foo</em></p><em>
</em><p><em>bar<a></a></em></p>
</body>rr)rrrrrr)rrrr	r	r
�+test_reparented_markup_ends_with_whitespaceQs
zDHTML5LibBuilderSmokeTest.test_reparented_markup_ends_with_whitespacecCsLd}|j|�}|jdd�\}}|jd�\}}|j|ks:t�|j|ksHt�dS)z�Verify that we keep the two whitespace nodes in this
        document distinct when reparenting the adjacent <tbody> tags.
        z,<table> <tbody><tbody><ims></tbody> </table>� )�stringZtbodyN)rr�next_element�AssertionError)rrrZspace1Zspace2Ztbody1Ztbody2r	r	r
�<test_reparented_markup_containing_identical_whitespace_nodesWs
zUHTML5LibBuilderSmokeTest.test_reparented_markup_containing_identical_whitespace_nodescCs^d}|j|�}|j}|jd|j�|jdd�}|jdd�d}|j||j�|j||j�dS)NzF<div><a>aftermath<p><noscript>target</noscript>aftermath</a></p></div>�target)r#Z	aftermath����)r�noscriptrr$�findrZprevious_element)rrrr*r'Zfinal_aftermathr	r	r
�*test_reparented_markup_containing_childrenbs
zCHTML5LibBuilderSmokeTest.test_reparented_markup_containing_childrencCs$d}|j|�}t|�jd�s t�dS)z(Processing instructions become comments.s<?PITarget PIContent?>z<!--?PITarget PIContent?-->N)rr�
startswithr%)rrrr	r	r
�test_processing_instructionrs
z4HTML5LibBuilderSmokeTest.test_processing_instructioncCs8d}|j|�}|jd�\}}|j||�||k	s4t�dS)Ns<a class="my_class"><p></a>�a)rrrr%)rrrZa1Za2r	r	r
�test_cloned_multivalue_nodexs

z4HTML5LibBuilderSmokeTest.test_cloned_multivalue_nodecCs$d}|j|�}|jd|jj��dS)Ns<table><td></tbody>Az><body>A<table><tbody><tr><td></td></tr></tbody></table></body>)rrrr)rrrr	r	r
�test_foster_parentings
z.HTML5LibBuilderSmokeTest.test_foster_parentingN)�__name__�
__module__�__qualname__�__doc__�propertyrrrrr r!r&r,r.r0r1r	r	r	r
rs
r)r5rZbs4.builderrZHTML5LIB_PRESENT�ImportError�eZbs4.elementrZbs4.testingrrrrr	r	r	r
�<module>s
Page not found – Hello World !