
    Mh                         d Z ddlZddlZddlmZ ddlmZ ddlmZ	m
Z
mZ ddlmZ ddlmZmZ erdd	lmZ erdd
lmZmZ  G d de          Z G d de          ZdS )zTests of the builder registry.    N)Type)BeautifulSoup)builder_registryTreeBuilderTreeBuilderRegistry)HTMLParserTreeBuilder   )HTML5LIB_PRESENTLXML_PRESENT)HTML5TreeBuilder)LXMLTreeBuilderForXMLLXMLTreeBuilderc                   *    e Zd ZdZd Zd Zd Zd ZdS )TestBuiltInRegistryz@Test the built-in registry with the default builders registered.c                 &   t          j        dd          t          k    sJ t          r@t          j        dd          t          k    sJ t          j        dd          t
          k    sJ t          r t          j        dd          t          k    sJ d S d S )Nstricthtmlfast
permissivexmlhtml5lib)registrylookupr   r   r   r   r
   r   selfs    _/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/bs4/tests/test_builder_registry.pytest_combinationz$TestBuiltInRegistry.test_combination#   s    x004IIIII 	Q?6622oEEEE?<77;PPPPP 	K?:v66:JJJJJ	K 	KJJ    c                 N   t           r@t          j        d          t          k    sJ t          j        d          t          k    sJ d S t          j        d          J t
          r!t          j        d          t          k    sJ d S t          j        d          t          k    sJ d S )Nr   r   )r   r   r   r   r   r
   r   r   r   s    r   test_lookup_by_markup_typez.TestBuiltInRegistry.test_lookup_by_markup_type+   s     	H?6**o====?5))-BBBBBBB?5))111 Hv..2BBBBBBBv..2GGGGGGGr   c                    t           r@t          j        dd          t          k    sJ t          j        dd          t          k    sJ t
          rt          j        d          t          k    sJ t          j        d          t          k    sJ d S )Nlxmlr   r   r   zhtml.parser)r   r   r   r   r   r
   r   r   r   s    r   test_named_libraryz&TestBuiltInRegistry.test_named_library6   s     	F?65115JJJJJ?6622oEEEE 	C?:..2BBBBB}--1FFFFFFFr   c                 0   t          j        d          5  t          dd           t          dddg           	 d d d            n# 1 swxY w Y   t          j        t
                    5  t          dd           d d d            d S # 1 swxY w Y   d S )NT)record r   )featuresr   zno-such-feature)warningscatch_warningsr   pytestraises
ValueErrorr   s    r   *test_beautifulsoup_constructor_does_lookupz>TestBuiltInRegistry.test_beautifulsoup_constructor_does_lookup?   s%   $D111 	 	
 "v...."'78888	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ]:&& 	: 	:"'89999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s#   %AAA,BBBN)__name__
__module____qualname____doc__r   r    r#   r-    r   r   r   r       s_        JJK K K	H 	H 	HG G G: : : : :r   r   c                   ^    e Zd ZdZd Zdedee         fdZd Z	d Z
d Zd	 Zd
 Zd Zd ZdS )TestRegistryz.Test the TreeBuilderRegistry class in general.c                 ,    t                      | _        d S N)r   r   r   s    r   setup_methodzTestRegistry.setup_methodS   s    +--r   feature_listreturnc                     t          dd                    |          z   t          fd|i          }| j                            |           |S )NBuilder__r'   )typejoinobjectr   register)r   r8   clss      r   builder_for_featuresz!TestRegistry.builder_for_featuresV   sM    ,///&Z<V
 
 	s###
r   c                     |                                  }| j                            d          J | j                                        |k    sJ d S )NfoorB   r   r   r   builders     r   test_register_with_no_featuresz+TestRegistry.test_register_with_no_features^   sX    ++-- }##E**222 }##%%000000r   c                     |                      dd          }| j                            d          |u sJ | j                            d          |u sJ d S NrD   barrE   rF   s     r   0test_register_with_features_makes_lookup_succeedz=TestRegistry.test_register_with_features_makes_lookup_succeedi   s_    ++E599}##E**g5555}##E**g555555r   c                 >    | j                             d          J d S )Nbazr   r   r   s    r   4test_lookup_fails_when_no_builder_implements_featurezATestRegistry.test_lookup_fails_when_no_builder_implements_featuren   s$    }##E**22222r   c                     |                      d           |                      d          }| j                                        |k    sJ d S rJ   rE   )r   builder2s     r   Ctest_lookup_gets_most_recent_registration_when_no_feature_specifiedzPTestRegistry.test_lookup_gets_most_recent_registration_when_no_feature_specifiedq   sN    !!%(((,,U33}##%%111111r   c                 <    | j                                         J d S r6   rO   r   s    r   2test_lookup_fails_when_no_tree_builders_registeredz?TestRegistry.test_lookup_fails_when_no_tree_builders_registeredv   s"    }##%%-----r   c                    |                      d           |                      d           |                      ddd          }|                      ddd          }|                      d           |                      d           | j                            dd          |k    sJ | j                            ddd          |k    sJ d S )NrD   rK   rN   quuxrE   )r   has_both_earlyhas_both_lates      r   <test_lookup_gets_most_recent_builder_supporting_all_featureszITestRegistry.test_lookup_gets_most_recent_builder_supporting_all_featuresy   s    !!%(((!!%(((225%GG11%GG!!%(((!!%((( }##E511]BBBB }##E5%88NJJJJJJr   c                     |                      dd           |                      dd           | j                            dd          J d S )NrD   rK   rN   rE   r   s    r   :test_lookup_fails_when_cannot_reconcile_requested_featureszGTestRegistry.test_lookup_fails_when_cannot_reconcile_requested_features   sR    !!%///!!%///}##E51199999r   N)r.   r/   r0   r1   r7   strr   r   rB   rH   rL   rP   rS   rU   rZ   r\   r2   r   r   r4   r4   P   s        88. . .# ${:K    	1 	1 	16 6 6
3 3 32 2 2
. . .K K K: : : : :r   r4   )r1   r*   r(   typingr   bs4r   bs4.builderr   r   r   r   bs4.builder._htmlparserr   r&   r
   r   bs4.builder._html5libr   bs4.builder._lxmlr   r   r?   r   r4   r2   r   r   <module>rd      sZ   $ $                       
 : 9 9 9 9 9       
  7666666        -: -: -: -: -:& -: -: -:`;: ;: ;: ;: ;:6 ;: ;: ;: ;: ;:r   