Файловый менеджер - Редактировать - /usr/lib/python3.6/site-packages/bs4/tests/__pycache__/test_builder_registry.cpython-36.pyc
Назад
3 c�T� � @ s� d Z ddlZddlZddlmZ ddlmZmZm Z yddlm Z dZW n ek r` dZY nX yddlm Z mZ dZW n ek r� dZY nX G d d � d ej�ZG dd� dej�ZdS ) zTests of the builder registry.� N)� BeautifulSoup)�builder_registry�HTMLParserTreeBuilder�TreeBuilderRegistry)�HTML5TreeBuilderTF)�LXMLTreeBuilderForXML�LXMLTreeBuilderc @ s0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd S )�BuiltInRegistryTestz@Test the built-in registry with the default builders registered.c C s` t r| jtjdd�t� t r0| jtjdd�t� | jtjdd�t� tr\| jtjdd�t� d S )N�fast�htmlZ permissive�xml�strict�html5lib) �LXML_PRESENT�assertEqual�registry�lookupr r r �HTML5LIB_PRESENTr )�self� r �+/usr/lib/python3.6/test_builder_registry.py�test_combination s z$BuiltInRegistryTest.test_combinationc C sj t r*| jtjd�t� | jtjd�t� n<| jtjd�d � trT| jtjd�t� n| jtjd�t� d S )Nr r ) r r r r r r r r r )r r r r �test_lookup_by_markup_type. s z.BuiltInRegistryTest.test_lookup_by_markup_typec C sX t r,| jtjdd�t� | jtjdd�t� trB| jtjd�t� | jtjd�t� d S )NZlxmlr r r zhtml.parser) r r r r r r r r r )r r r r �test_named_library9 s z&BuiltInRegistryTest.test_named_libraryc C sJ t jdd��"}tddd� tdddgd� W d Q R X | jttddd� d S )NT)�record� r )�featuresr zno-such-feature)�warnings�catch_warningsr ZassertRaises� ValueError)r �wr r r �*test_beautifulsoup_constructor_does_lookupF s z>BuiltInRegistryTest.test_beautifulsoup_constructor_does_lookupN)�__name__� __module__�__qualname__�__doc__r r r r! r r r r r s r c @ sX e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z dd� Zdd� ZdS )�RegistryTestz.Test the TreeBuilderRegistry class in general.c C s t � | _d S )N)r r )r r r r �setUpY s zRegistryTest.setUpc G s, t ddj|� tfd|i�}| jj|� |S )NZBuilder_�_r )�type�join�objectr �register)r Zfeature_list�clsr r r �builder_for_features\ s z!RegistryTest.builder_for_featuresc C s2 | j � }| j| jjd�d � | j| jj� |� d S )N�foo)r. r r r )r �builderr r r �test_register_with_no_featuresc s z+RegistryTest.test_register_with_no_featuresc C s8 | j dd�}| j| jjd�|� | j| jjd�|� d S )Nr/ �bar)r. r r r )r r0 r r r �0test_register_with_features_makes_lookup_succeedn s z=RegistryTest.test_register_with_features_makes_lookup_succeedc C s$ | j dd�}| j| jjd�d � d S )Nr/ r2 �baz)r. r r r )r r0 r r r �4test_lookup_fails_when_no_builder_implements_features s zARegistryTest.test_lookup_fails_when_no_builder_implements_featurec C s* | j d�}| j d�}| j| jj� |� d S )Nr/ r2 )r. r r r )r �builder1�builder2r r r �Ctest_lookup_gets_most_recent_registration_when_no_feature_specifiedw s zPRegistryTest.test_lookup_gets_most_recent_registration_when_no_feature_specifiedc C s | j | jj� d � d S )N)r r r )r r r r �2test_lookup_fails_when_no_tree_builders_registered| s z?RegistryTest.test_lookup_fails_when_no_tree_builders_registeredc C sv | j d�}| j d�}| j ddd�}| j ddd�}| j d�}| j d�}| j| jjdd�|� | j| jjddd�|� d S )Nr/ r2 r4 Zquux)r. r r r )r Zhas_oneZ has_the_otherZhas_both_earlyZ has_both_lateZ lacks_oner r r �<test_lookup_gets_most_recent_builder_supporting_all_features s zIRegistryTest.test_lookup_gets_most_recent_builder_supporting_all_featuresc C s2 | j dd�}| j dd�}| j| jjdd�d � d S )Nr/ r2 r4 )r. r r r )r r6 r7 r r r �:test_lookup_fails_when_cannot_reconcile_requested_features� s zGRegistryTest.test_lookup_fails_when_cannot_reconcile_requested_featuresN) r"