| Server IP : 209.209.40.120 / Your IP : 216.73.217.112 Web Server : Microsoft-IIS/10.0 System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586 User : NEWWWW$ ( 0) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Python312/Lib/site-packages/bs4/tests/__pycache__/ |
Upload File : |
�
V �g�# � � � d Z ddlZddlZddlmZ ddlmZ ddlmZm Z ej j e d�� G d � d
e � � Zy)zDTests to ensure that the html5lib tree builder generates good trees.� N)�
BeautifulSoup)�SoupStrainer� )�HTML5LIB_PRESENT�HTML5TreeBuilderSmokeTestz?html5lib seems not to be present, not testing its tree builder.)�reasonc �� � e Zd ZdZed� � Zd� Zd� Zd� Zd� Z d� Z
d� Zd � Zd
� Z
d� Zd� Zd
� Zd� Zd� Zd� Zd� Zej, j/ ddddgfg� d� � Zd� Zy)�TestHTML5LibBuilderz"See ``HTML5TreeBuilderSmokeTest``.c � � ddl m} |S )Nr )�HTML5TreeBuilder)�bs4.builderr )�selfr s �9C:\Python312\Lib\site-packages\bs4/tests/test_html5lib.py�default_builderz#TestHTML5LibBuilder.default_builder s � �0��� c �< � t d� }d}t j d�� 5 }t |d|�� }d d d � j � | j |� k( sJ �\ }|j t k( sJ �dt |j � v sJ �y # 1 sw Y �`xY w)N�bz<p>A <b>bold</b> statement.</p>T��record�html5lib)�
parse_onlyz4the html5lib tree builder doesn't support parse_only)
r �warnings�catch_warningsr �decode�document_for�filename�__file__�str�message)r �strainer�markup�w�soup�warnings r �test_soupstrainerz%TestHTML5LibBuilder.test_soupstrainer s� � ���$��2��
�
$�
$�D�
1� J�Q� ����I�D� J��{�{�}�� 1� 1�&� 9�9�9�9�� �����8�+�+�+�E���O�O�J
�
�
�
�
J� J�s �B�Bc �N � d}| j |d� | j d� y)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)�assert_soup)r r! s r �test_correctly_nested_tablesz0TestHTML5LibBuilder.test_correctly_nested_tables) s9 � �
� �
����
)�
�
���
;�
r c �h � d}| j |� }d|j j � k( sJ �y )Nzy<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>foo</p>
</body>
</html>s
<p>foo</p>)r# �p�encode�r r! r# s r �(test_xml_declaration_followed_by_doctypez<TestHTML5LibBuilder.test_xml_declaration_followed_by_doctypeA s1 � ��� �y�y�� ������
�
��/�/�/r c � � d}| j |� }d|j j � k( sJ �dt |j d� � k( sJ �y )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* �r# �bodyr �len�find_allr, s r �test_reparented_markupz*TestHTML5LibBuilder.test_reparented_markupO sU � �9���y�y�� ��S��y�y���!�
"�
�
"� �C��
�
�c�*�+�+�+�+r c � � d}| j |� }d|j j � k( sJ �dt |j d� � k( sJ �y )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>r/ r* r0 r, s r �+test_reparented_markup_ends_with_whitespacez?TestHTML5LibBuilder.test_reparented_markup_ends_with_whitespaceX sU � �;���y�y�� ��U��y�y���!�
"�
�
"� �C��
�
�c�*�+�+�+�+r c � � d}| j |� }|j d�� \ }}|j d� \ }}|j |u sJ �|j |u sJ �y)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>� ��string�tbodyN)r# r3 �next_element)r r! r# �space1�space2�tbody1�tbody2s r �<test_reparented_markup_containing_identical_whitespace_nodeszPTestHTML5LibBuilder.test_reparented_markup_containing_identical_whitespace_nodesa sf � � @���y�y�� �����c��2�������w�/�����"�"�f�,�,�,��"�"�f�,�,�,r c � � d}| j |� }|j }d|j k( sJ �|j d�� }|j d�� d }||j k( sJ �||j
k( sJ �y )NzF<div><a>aftermath<p><noscript>target</noscript>aftermath</a></p></div>�targetr9 � aftermath���)r# �noscriptr<