← Back
Editing: test_tag.cpython-311.pyc
� ���c8# � �b � d dl Z d dlmZmZ ddlmZ G d� de� � Z G d� de� � ZdS ) � N)�Comment�NavigableString� )�SoupTestc �l � e Zd ZdZd� Zd� Zd� Zd� Zd� Zd� Z d� Z d � Zd � Zd� Z d� Zd � Zd� Zd� Zd� ZdS )�TestTagz]Test various methods of Tag which aren't so complicated they need their own classes. c �^ � | � d� � � d� � }d |_ d|� d� � k sJ �dg|_ d|� d� � k sJ �d|� d � � k sJ �ddg|_ d|� d� � k sJ �d S )N� �a_tagTr �some_other_tagr F)�soup�new_tag�_preserve_whitespace_tags�_should_pretty_print�preserve_whitespace_tags)�self�tags �4/usr/lib/python3/dist-packages/bs4/tests/test_tag.py�test__should_pretty_printz!TestTag.test__should_pretty_print s� � ��i�i��m�m�#�#�G�,�,�� )-��%��s�/�/��2�2�2�2�2�2� )9�'9��$��s�/�/��2�2�2�2�2�2� ��0�0��6�6�6�6�6�6� )9�'�'B��$���0�0��3�3�3�3�3�3�3�3� c � � | � d� � }t |j � � dk sJ �t |� � dk sJ �t |j � � dk sJ �t |j j � � dk sJ �dS )z.The length of a Tag is its number of children.z<top>1<b>2</b>3</top>r � N)r �len�contents�top�r r s r �test_lenzTestTag.test_len s� � ��y�y�0�1�1�� �4�=�!�!�Q�&�&�&�&��4�y�y�A�~�~�~�~� �4�8�}�}��!�!�!�!��4�8�$�%�%��*�*�*�*�*�*r c � � | � d� � }|j |� d� � k sJ �|j j |� d� � � d� � k sJ �|j dk sJ �dS )z2Accessing a Python member .foo invokes find('foo')�<b><i></i></b>�b�iN)r r �findr! �ar s r �test_member_access_invokes_findz'TestTag.test_member_access_invokes_find. sq � ��y�y�)�*�*���v����3���'�'�'�'��v�x�4�9�9�S�>�>�.�.�s�3�3�3�3�3�3��v��~�~�~�~�~�~r c �� � | � d� � }t j d�� � 5 }|j }d d d � � n# 1 swxY w Y |j |k sJ �dt |d j � � k sJ �d S )Nr T)�recordzp.bTag is deprecated, use .find("b") instead. If you really were looking for a tag called bTag, use .find("bTag")r )r �warnings�catch_warnings�bTagr �str�message)r r �wr s r �test_deprecated_member_accessz%TestTag.test_deprecated_member_access5 s� � ��y�y�)�*�*�� � $�D� 1� 1� 1� �Q��)�C� � � � � � � � � � � ���� � � � ��v��}�}�}�}� B� FI� JK� LM� JN� JV� FW� FW� W� W� W� W� W� Ws �?�A�Ac � � | � d� � }|j � d� � sJ �|j � d� � rJ �dS )z�has_attr() checks for the presence of an attribute. Please note note: has_attr() is different from __in__. has_attr() checks the tag's attributes and __in__ checks the tag's chidlren. z<foo attr='bar'>�attr�attr2N)r �foo�has_attrr s r � test_has_attrzTestTag.test_has_attr<