U
    }g                     @   sh   d Z ddlZddlmZmZmZmZmZmZ G dd dZ	G dd dZ
G dd	 d	ZG d
d dZdS )zTests of classes in element.py.

The really big classes -- Tag, PageElement, and NavigableString --
are tested in separate files.
    N)HTMLAttributeDictXMLAttributeDictCharsetMetaAttributeValueContentMetaAttributeValueNamespacedAttribute	ResultSetc                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestNamedspacedAttributec                 C   sD   t dd }|dkstt dd}|dks,tt d}|dks@td S )Nxmlns r   AssertionErrorselfa r   :/tmp/pip-unpacked-wheel-kgiupv3k/bs4/tests/test_element.py test_name_may_be_none_or_missing   s    

z9TestNamedspacedAttribute.test_name_may_be_none_or_missingc                 C   s0   t d d}|dkstt dd}|dks,td S )Ntagr
   r   r   r   r   r   %test_namespace_may_be_none_or_missing   s    

z>TestNamedspacedAttribute.test_namespace_may_be_none_or_missingc                 C   s   t dd}d|kstd S )Nr   bza:br   r   r   r   r   6test_attribute_is_equivalent_to_colon_separated_string#   s    
zOTestNamedspacedAttribute.test_attribute_is_equivalent_to_colon_separated_stringc                 C   sp   t ddd}t ddd}||ks$tt ddd }||ks<tt ddd}||ksTtt ddd}||ksltd S )Nr   r   czr   )r   r   r   r   der   r   r   ;test_attributes_are_equivalent_if_prefix_and_name_identical'   s    zTTestNamedspacedAttribute.test_attributes_are_equivalent_if_prefix_and_name_identicalN)__name__
__module____qualname__r   r   r   r   r   r   r   r   r      s   
r   c                   @   s    e Zd ZdZdd Zdd ZdS ))TestAttributeValueWithCharsetSubstitutionzpCertain attributes are designed to have the charset of the
    final document substituted into their value.
    c                 C   s\   t d}d|kstd|jks"td|dks4td|dksFtd|dksXtd S )Nzeuc-jputf8asciir
   palmos)r   r   original_valuesubstitute_encodingr   valuer   r   r   !test_charset_meta_attribute_value=   s    zKTestAttributeValueWithCharsetSubstitution.test_charset_meta_attribute_valuec                 C   s\   t d}d|kstd|jks"td|dks4td|dksFtd|dksXtd S )Nztext/html; charset=euc-jpztext/html; charset=utf8r    ztext/html; charset=asciir!   z	text/htmlr"   )r   r   r#   r$   r%   r   r   r   !test_content_meta_attribute_valueJ   s    zKTestAttributeValueWithCharsetSubstitution.test_content_meta_attribute_valueN)r   r   r   __doc__r'   r(   r   r   r   r   r   8   s   r   c                   @   s   e Zd Zdd Zdd ZdS )TestAttributeDictsc                 C   s   t  }d|d< |d dkstd|d< |d dks6td|d< |d dksNtd|d< |d dksftd |d< |d dks~td S )	Nd   v100Zd;Y@100.123FTr
   )r   r   )r   r   r   r   r   !test_xml_attribute_value_handlingW   s    z4TestAttributeDicts.test_xml_attribute_value_handlingc                 C   s   t  }d|d< |d dkstd|d< |d dks6td|d< d|ksJtd |d< d|ks^td|d< |d dksvttdd	d
}d||< || d	kstd S )Nr+   r,   r-   r.   r/   FTprefixname	namespace)r   r   r   )r   r   	attributer   r   r   "test_html_attribute_value_handlingk   s    z5TestAttributeDicts.test_html_attribute_value_handlingN)r   r   r   r0   r5   r   r   r   r   r*   V   s   r*   c                   @   s   e Zd Zdd ZdS )TestResultSetc              	   C   s:   t d }tt}|j W 5 Q R X dt|jks6td S )NzResultSet object has no attribute "name". You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?)r   pytestZraisesAttributeErrorr2   strr&   r   )r   rsr   r   r   r   test_getattr_exception   s    z$TestResultSet.test_getattr_exceptionN)r   r   r   r;   r   r   r   r   r6      s   r6   )r)   r7   Zbs4.elementr   r   r   r   r   r   r   r   r*   r6   r   r   r   r   <module>   s    	',