
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>

_[c           @   s  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l	 m
 Z
 m Z d d l m Z m Z m Z m Z m Z m Z m Z m Z d d l m Z m Z e
 j d  e k	 Z e
 j d	  e k	 Z d
 e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ  d e f d     YZ! d e f d     YZ" d e f d     YZ# d e f d     YZ$ d e$ f d     YZ% d e$ f d     YZ& d  e f d!     YZ' d" e' f d#     YZ( d$ e' f d%     YZ) d& e f d'     YZ* d( e f d)     YZ+ d* e f d+     YZ, d, e f d-     YZ- d. e f d/     YZ. d0 e f d1     YZ/ d2 e f d3     YZ0 d4 e f d5     YZ1 d6 e f d7     YZ2 d S(8   s8  Tests for Beautiful Soup's tree traversal methods.

The tree traversal methods are the main advantage of using Beautiful
Soup over just using a parser.

Different parsers will build different Beautiful Soup trees given the
same markup, but all Beautiful Soup trees can be traversed with the
methods tested here.
i(   t	   set_traceN(   t   BeautifulSoup(   t   builder_registryt   HTMLParserTreeBuilder(   t   PY3Kt   CDatat   Commentt   Declarationt   Doctypet   NavigableStringt   SoupStrainert   Tag(   t   SoupTestt   skipIft   xmlt   lxmlt   TreeTestc           B   s   e  Z d    Z d   Z RS(   c         C   s*   |  j  g  | D] } | j ^ q |  d S(   s   Make sure that the given tags have the correct text.

        This is used in tests that define a bunch of tags, each
        containing a single string, and then select certain strings by
        some mechanism.
        N(   t   assertEqualt   string(   t   selft   tagst   should_matcht   tag(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   assertSelects+   s    c         C   s+   |  j  g  | D] } | d ^ q |  d S(   s   Make sure that the given tags have the correct IDs.

        This is used in tests that define a bunch of tags, each
        containing a single string, and then select certain strings by
        some mechanism.
        t   idN(   R   (   R   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   assertSelectsIDs4   s    (   t   __name__t
   __module__R   R   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR   )   s   		t   TestFindc           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s   Basic tests of the find() method.

    find() just calls find_all() with limit=1, so it's not tested all
    that thouroughly here.
    c         C   s/   |  j  d  } |  j | j d  j d  d  S(   Ns    <a>1</a><b>2</b><a>3</a><b>4</b>t   bt   2(   t   soupR   t   findR   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_tagE   s    c         C   s/   |  j  d  } |  j | j d d  d  d  S(   Nu   <h1>Räksmörgås</h1>R   u   Räksmörgås(   R   R   R    (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_unicode_text_findI   s    c         C   s<   |  j  d  } t |  |  j d | j d d  j  d  S(   Nu&   <h1 id="Räksmörgås">here it is</h1>s
   here it isR   u   Räksmörgås(   R   t   strR   R    t   text(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_unicode_attribute_findM   s    
c         C   s/   |  j  d  } |  j d t | j     d S(   s)   Test an optimization that finds all tags.s   <a>foo</a><b>bar</b>i   N(   R   R   t   lent   find_all(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_everythingS   s    c         C   s2   |  j  d  } |  j d t | j d    d S(   s;   Test an optimization that finds all tags with a given name.s   <a>foo</a><b>bar</b><a>baz</a>i   t   aN(   R   R   R&   R'   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_everything_with_nameX   s    (   R   R   t   __doc__R!   R"   R%   R(   R*   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR   >   s   				t   TestFindAllc           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s%   Basic tests of the find_all() method.c         C   s   |  j  d  } |  j | j d d  d g  |  j | j d d  d g  |  j | j d d d g  d d g  |  j | j d t j d   d d d	 g  |  j | j d t  d d d	 g  d
 S(   s'   You can search the tree for text nodes.s   <html>Foo<b>bar</b></html>R   t   baru   barR$   t   Foou   Foos   .*u   »N(   R   R   R'   t   ret   compilet   True(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_text_nodes`   s    "c         C   s   |  j  d  } |  j | j d d d d d d g  |  j | j d d d d g  |  j | j d d d	 d d d d
 d g  |  j | j d d d d d d d
 d g  d S(   s7   You can limit the number of items returned by find_all.s(   <a>1</a><a>2</a><a>3</a><a>4</a><a>5</a>R)   t   limiti   t   1R   t   3i   i
   t   4t   5i    N(   R   R   R'   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_limitp   s    ("(c         C   sQ   |  j  d  } |  j | d d d d g  |  j | j d d  d g  d  S(	   Ns!   <a>1</a><b>2<a id='foo'>3</a></b>R)   R3   i   R4   R   t   fooR5   (   R   R   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt%   test_calling_a_tag_is_calling_findall|   s    c         C   s?   |  j  d  } g  } | j |  |  j g  | j |   d  S(   Ns   <a></a>(   R   t   appendR   R'   (   R   R   t   l(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pytT   test_find_all_with_self_referential_data_structure_does_not_cause_infinite_recursion   s    c         C   s   |  j  d  } | j d  } |  j t | d   | j t  } |  j t | d   | j d d  } |  j t | d   d S(   s%   All find_all calls return a ResultSets   <a></a>R)   t   sourceR$   R9   N(   R   R'   t
   assertTruet   hasattrR1   (   R   R   t   result(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_resultset   s    (   R   R   R+   R2   R8   R:   R=   RB   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR,   ]   s   				
t   TestFindAllBasicNamespacesc           B   s   e  Z d    Z RS(   c         C   sU   |  j  d  } |  j d | j d  j  |  j d | j d i d d 6 j  d  S(   Ns0   <mathml:msqrt>4</mathml:msqrt><a svg:fill="red">R6   s   mathml:msqrtR)   t   attrst   reds   svg:fill(   R   R   R    R   t   name(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_by_namespaced_name   s    (   R   R   RG   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRC      s   t   TestFindAllByNamec           B   sq   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z RS(   s&   Test ways of finding tags by tag name.c         C   s)   t  t |   j   |  j d  |  _ d  S(   Ns   <a>First tag.</a>
                                  <b>Second tag.</b>
                                  <c>Third <a>Nested tag.</a> tag.</c>(   t   superR   t   setUpR   t   tree(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRJ      s    c         C   s&   |  j  |  j j d  d d g  d  S(   NR)   s
   First tag.s   Nested tag.(   R   RK   R'   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_by_tag_name   s    c         C   s   |  j  |  j j d d d d g  |  j  |  j j d d t d d g  |  j  |  j j d d t j d  d d g  d  S(   NR)   R$   s
   First tag.s   Nested tag.R   (   R   RK   R'   R1   R/   R0   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_by_name_and_text   s    "c         C   s&   |  j  |  j j j d  d g  d  S(   NR)   s   Nested tag.(   R   RK   t   cR'   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt!   test_find_all_on_non_root_element   s    c         C   s#   |  j  |  j d  d d g  d  S(   NR)   s
   First tag.s   Nested tag.(   R   RK   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt%   test_calling_element_invokes_find_all   s    c         C   s,   |  j  |  j j t d   d d g  d  S(   NR)   s
   First tag.s   Nested tag.(   R   RK   R'   R
   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_by_tag_strainer   s    c         C   s/   |  j  |  j j d d g  d d d g  d  S(   NR)   R   s
   First tag.s   Second tag.s   Nested tag.(   R   RK   R'   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_by_tag_names   s    c         C   s7   |  j  |  j j i t d 6t d 6 d d d g  d  S(   NR)   R   s
   First tag.s   Second tag.s   Nested tag.(   R   RK   R'   R1   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_by_tag_dict   s    c         C   s2   |  j  |  j j t j d   d d d g  d  S(   Ns   ^[ab]$s
   First tag.s   Second tag.s   Nested tag.(   R   RK   R'   R/   R0   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_by_tag_re   s    c         C   s;   d   } |  j  d  } |  j | j |  d d g  d  S(   Nc         S   s   |  j  |  j d  k S(   NR   (   RF   t   get(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   id_matches_name   s    s   <a id="a">Match 1.</a>
                            <a id="1">Does not match.</a>
                            <b id="b">Match 2.</a>s   Match 1.s   Match 2.(   R   R   R'   (   R   RV   RK   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt'   test_find_all_with_tags_matching_method   s
    		c         C   s   |  j  d  } | j d d  } | j d t j d   } | j d d d g  \ } } |  j d | j  |  j d | j  |  j d | j  |  j d | j  d  S(   NsH   <div class='a b'>1</div><div class='a c'>2</div><div class='a d'>3</div>t   divs   a ds   a bR5   R4   (   R   R    R/   R0   R'   R   R   (   R   R   t   r1t   r2t   r3t   r4(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt%   test_find_with_multi_valued_attribute   s    	(   R   R   R+   RJ   RL   RM   RO   RP   RQ   RR   RS   RT   RW   R]   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRH      s   										t   TestFindAllByAttributec           B   s   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s5   |  j  d  } |  j | j d d  d d g  d  S(   Ns   
                         <a id="first">Matching a.</a>
                         <a id="second">
                          Non-matching <b id="first">Matching b.</b>a.
                         </a>R   t   firsts   Matching a.s   Matching b.(   R   R   R'   (   R   RK   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_by_attribute_name   s    	c         C   s   d j  d  } d j  d  } |  j |  } |  j | j g | j d |   |  j | j g | j d | j d    |  j | j g | j d | d g   d  S(   Nu   םולשt   utf8u   <a title="םולש"></a>t   titles   something else(   t   encodeR   R   R)   R'   t   decode(   R   t   peacet   dataR   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt%   test_find_all_by_utf8_attribute_value   s    "+c         C   s~   |  j  d  } |  j | j d d  d g  |  j | j d i d d 6 d g  |  j | j d i d d 6 d	 g  d  S(
   Ns0  
                         <a name="name1" class="class1">Name match.</a>
                         <a name="name2" class="class2">Class match.</a>
                         <a name="name3" class="class3">Non-match.</a>
                         <name1>A tag called 'name1'.</name1>
                         RF   t   name1s   A tag called 'name1'.RD   s   Name match.t   class2t   classs   Class match.(   R   R   R'   (   R   RK   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_by_attribute_dict  s    	

c         C   s   |  j  d  } |  j | j d d d d g  |  j | j d d d d g  |  j | j d d d	 d g  |  j | j d d  d g  |  j | j d
 d  d d g  |  j | j d d  d g  |  j | j d d	  d g  d  S(   Ns   
                         <a class="1">Class 1.</a>
                         <a class="2">Class 2.</a>
                         <b class="1">Class 1.</b>
                         <c class="3 4">Class 3 and 4.</c>
                         R)   t   class_R4   s   Class 1.RN   R5   s   Class 3 and 4.R6   RD   (   R   R   R'   (   R   RK   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_by_class  s    	""""c         C   s   |  j  d  } | j d d t j d  } |  j | d g  | j d d t j d  } |  j | d g  | j d d t j d  } |  j | d g  d  S(   Ns#   <gar class='foo bar'>Found it</gar>t   garRl   t   os   Found itR)   s   o b(   R   R'   R/   R0   R   (   R   RK   t   f(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt0   test_find_by_class_when_multiple_classes_present-  s    c         C   s   |  j  d  } |  j | j d t j d   d g  d   } |  j | j d |  g   d   } |  j | j d |  d g  d  S(   Ns   <a class='bar'>Found it</a>R)   t   bas   Found itc         S   s   t  |   d k S(   Ni   (   R&   (   t   value(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   big_attribute_value@  s    c         S   s   t  |   d k S(   Ni   (   R&   (   Rs   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   small_attribute_valueE  s    (   R   R   R'   R/   R0   (   R   R   Rt   Ru   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt:   test_find_all_with_non_dictionary_for_attrs_finds_by_class;  s    (		c         C   s   |  j  d  } | j d  \ } } |  j | | g | j d d   |  j | g | j d d   |  j | g | j d d d  |  j | g | j d d   |  j g  | j d d   d  S(   Ns*   <a class="foo bar"></a><a class="foo"></a>R)   R9   R-   Rl   s   foo bars   bar foo(   R   R'   R   (   R   R   R)   t   a2(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt:   test_find_all_with_string_for_attrs_finds_multiple_classesK  s    ""c         C   sE   |  j  d  } t d i d d 6 } |  j | j |  d g  d  S(   Nsi   
                         <a id="first">Match.</a>
                         <a id="second">Non-match.</a>RD   R_   R   s   Match.(   R   R
   R   R'   (   R   RK   t   strainer(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt'   test_find_all_by_attribute_soupstrainerW  s    	c         C   s5   |  j  d  } |  j | j d d d  d g  d  S(   Ns   <a id="1">ID present.</a>
                            <a>No ID present.</a>
                            <a id="">ID is empty.</a>R)   R   s   No ID present.(   R   R   R'   t   None(   R   RK   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt$   test_find_all_with_missing_attribute_  s    	c         C   s5   |  j  d  } |  j | j d t  d d g  d  S(   Ns   <a id="1">ID present.</a>
                            <a>No ID present.</a>
                            <a id="">ID is empty.</a>R   s   ID present.s   ID is empty.(   R   R   R'   R1   (   R   RK   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt$   test_find_all_with_defined_attributeg  s    	c         C   sW   |  j  d  } d d g } |  j | j d d  |  |  j | j d d  |  d  S(   Ns[   <a id=1>Unquoted attribute.</a>
                            <a id="1">Quoted attribute.</a>s   Unquoted attribute.s   Quoted attribute.R   i   R4   (   R   R   R'   (   R   RK   t   expected(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt$   test_find_all_with_numeric_attributep  s
    	c         C   s>   |  j  d  } |  j | j d d d d g  d d g  d  S(   Ns   <a id="1">1</a>
                            <a id="2">2</a>
                            <a id="3">3</a>
                            <a>No ID.</a>R   R4   R5   R6   (   R   R   R'   (   R   RK   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt(   test_find_all_with_list_attribute_valuesy  s    	c         C   s>   |  j  d  } |  j | j d t j d   d d g  d  S(   Ns   <a id="a">One a.</a>
                            <a id="aa">Two as.</a>
                            <a id="ab">Mixed as and bs.</a>
                            <a id="b">One b.</a>
                            <a>No ID.</a>R   s   ^a+$s   One a.s   Two as.(   R   R   R'   R/   R0   (   R   RK   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt5   test_find_all_with_regular_expression_attribute_value  s    	c         C   s|   |  j  d  } | j } |  j | g | j d d d  |  j g  | j d d d  |  j g  | j d d d  d  S(   Ns   <b>foo</b><b>bar</b><a>foo</a>R)   R$   R9   R-   (   R   R)   R   R'   (   R   R   R)   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt'   test_find_by_name_and_containing_string  s
    	"c         C   s;   |  j  d  } |  j | j d  | j d d d  d  S(   Ns"   <a>foo</a><a><b><c>foo</c></b></a>R)   R$   R9   (   R   R   R'   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt=   test_find_by_name_and_containing_string_when_string_is_buried  s    c         C   sc   |  j  d  } | j } |  j | g | j d d d d   |  j g  | j d d d d   d  S(   Ns"   <b id="1">foo</b><a id="2">foo</a>R   i   R$   R9   i   R-   (   R   R)   R   R'   (   R   R   R)   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt,   test_find_by_attribute_and_containing_string  s    	%(   R   R   R`   Rg   Rk   Rm   Rq   Rv   Rx   Rz   R|   R}   R   R   R   R   R   R   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR^      s    														
			t	   TestIndexc           B   s   e  Z d  Z d   Z RS(   s   Test Tag.indexc         C   sk   |  j  d  } | j } x6 t | j  D]% \ } } |  j | | j |   q( W|  j t | j d  d  S(   Nsh  <div>
                            <a>Identical</a>
                            <b>Not identical</b>
                            <a>Identical</a>

                            <c><d>Identical with child</d></c>
                            <b>Also not identical</b>
                            <c><d>Identical with child</d></c>
                            </div>i   (   R   RX   t	   enumeratet   contentsR   t   indext   assertRaisest
   ValueError(   R   RK   RX   t   it   element(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt
   test_index  s    		(   R   R   R+   R   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR     s   t   TestParentOperationsc           B   s_   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(
   s;   Test navigation and searching through an element's parents.c         C   s8   t  t |   j   |  j d  |  _ |  j j |  _ d  S(   Ns1  <ul id="empty"></ul>
                                 <ul id="top">
                                  <ul id="middle">
                                   <ul id="bottom">
                                    <b>Start here</b>
                                   </ul>
                                  </ul>(   RI   R   RJ   R   RK   R   t   start(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRJ     s    c         C   s[   |  j  |  j j d d  |  j  |  j j j d d  |  j  |  j j j j d d  d  S(   NR   t   bottomt   middlet   top(   R   R   t   parent(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_parent  s    c         C   s*   |  j  j d } |  j | j |  j   d  S(   Ni    (   RK   R   R   R   (   R   t   top_tag(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt%   test_parent_of_top_tag_is_soup_object  s    c         C   s   |  j  d  |  j j  d  S(   N(   R   R{   RK   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_soup_object_has_no_parent  s    c         C   sN   |  j  |  j j d  d d d g  |  j  |  j j d d d d g  d  S(   Nt   ulR   R   R   R   (   R   R   t   find_parents(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_parents  s    c         C   sJ   |  j  |  j j d  d d  |  j  |  j j d d d d d  d  S(   NR   R   R   R   (   R   R   t   find_parent(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_parent  s     c         C   s/   |  j  j d d  } |  j | j j d  d  S(   NR$   s
   Start hereR   (   RK   R    R   R   RF   (   R   R$   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_parent_of_text_element  s    c         C   s6   |  j  j d d  } |  j | j d  d d  d  S(   NR$   s
   Start hereR   R   R   (   RK   R    R   R   (   R   R$   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_text_element_find_parent  s    c         C   s[   g  |  j  j D]+ } | d  k	 r d | j k r | d ^ q } |  j | d d d g  d  S(   NR   R   R   R   (   R   t   parentsR{   RD   R   (   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_parent_generator  s    +(   R   R   R+   RJ   R   R   R   R   R   R   R   R   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR     s   								t   ProximityTestc           B   s   e  Z d    Z RS(   c         C   s)   t  t |   j   |  j d  |  _ d  S(   Nsg   <html id="start"><head></head><body><b id="1">One</b><b id="2">Two</b><b id="3">Three</b></body></html>(   RI   R   RJ   R   RK   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRJ     s    (   R   R   RJ   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR     s   t   TestNextOperationsc           B   sP   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   c         C   s&   t  t |   j   |  j j |  _ d  S(   N(   RI   R   RJ   RK   R   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRJ     s    c         C   s7   |  j  |  j j d  |  j  |  j j j d d  d  S(   Nt   OneR   R   (   R   R   t   next_element(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt	   test_next  s    c         C   s,   |  j  j d d  } |  j | j d   d  S(   NR$   t   Three(   RK   R    R   R   R{   (   R   t   last(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_next_of_last_item_is_none  s    c         C   s   |  j  |  j j d   d  S(   N(   R   RK   R   R{   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_next_of_root_is_none  s    c         C   s[   |  j  |  j j d  d d g  |  j j d d  |  j  |  j j d d  d g  d  S(   NR   t   TwoR   R   i   (   R   R   t   find_all_next(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_next  s    "c         C   sC   |  j  |  j j d  d d  |  j  |  j j d d  d  d  S(   NR   R   R   R$   R   (   R   R   t	   find_next(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_next
  s     c         C   sT   |  j  j d d  } |  j | j d  j d  |  j | j d  d d g  d  S(   NR$   R   R   R   R   (   RK   R    R   R   R   R   R   (   R   R$   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_next_for_text_element  s    c         C   se   |  j  j d d  } g  | j D] } | ^ q } | \ } } |  j | d d  |  j | d  d  S(   NR$   R   R   R5   R   (   RK   R    t   next_elementsR   (   R   R   t   nodet
   successorsR   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_next_generator  s
    (
   R   R   RJ   R   R   R   R   R   R   R   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR     s   							t   TestPreviousOperationsc           B   sP   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   c         C   s/   t  t |   j   |  j j d d  |  _ d  S(   NR$   R   (   RI   R   RJ   RK   R    t   end(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRJ     s    c         C   s7   |  j  |  j j d d  |  j  |  j j j d  d  S(   NR   R5   R   (   R   R   t   previous_element(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_previous!  s    c         C   s)   |  j  j d  } |  j | j d   d  S(   Nt   html(   RK   R    R   R   R{   (   R   R_   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt#   test_previous_of_first_item_is_none%  s    c         C   s   d  S(   N(    (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_previous_of_root_is_none)  s    c         C   sK   |  j  |  j j d  d d d g  |  j  |  j j d d  d g  d  S(   NR   R   R   R   R   i   (   R   R   t   find_all_previous(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_all_previous/  s    c         C   sC   |  j  |  j j d  d d  |  j  |  j j d d  d  d  S(   NR   R   R5   R$   R   (   R   R   t   find_previous(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_previous7  s     c         C   sW   |  j  j d d  } |  j | j d  j d  |  j | j d  d d d g  d  S(   NR$   R   R   R   R   (   RK   R    R   R   R   R   R   (   R   R$   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt#   test_find_previous_for_text_element;  s    c         C   s   |  j  j d d  } g  | j D] } | ^ q } | \ } } } } |  j | d d  |  j | j d  |  j | j d  |  j | j d  d  S(   NR$   R   R   R4   t   bodyt   headR   (   RK   R    t   previous_elementsR   RF   (   R   R   R   t   predecessorsR   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_previous_generatorA  s    (
   R   R   RJ   R   R   R   R   R   R   R   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR     s   							t   SiblingTestc           B   s   e  Z d    Z RS(   c         C   sJ   t  t |   j   d } t j d  j d |  } |  j |  |  _ d  S(   Ns  <html>
                    <span id="1">
                     <span id="1.1"></span>
                    </span>
                    <span id="2">
                     <span id="2.1"></span>
                    </span>
                    <span id="3">
                     <span id="3.1"></span>
                    </span>
                    <span id="4"></span>
                    </html>s   \n\s*t    (   RI   R   RJ   R/   R0   t   subR   RK   (   R   t   markup(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRJ   P  s    (   R   R   RJ   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR   N  s   t   TestNextSiblingc           B   sG   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s/   t  t |   j   |  j j d d  |  _ d  S(   NR   R4   (   RI   R   RJ   RK   R    R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRJ   f  s    c         C   s   |  j  |  j j d   d  S(   N(   R   RK   t   next_siblingR{   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt!   test_next_sibling_of_root_is_nonej  s    c         C   sU   |  j  |  j j d d  |  j  |  j j j d d  |  j  |  j j d d  d  S(   NR   R   R5   s   1.1(   R   R   R   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_next_siblingm  s    c         C   sm   |  j  |  j j j d   |  j j d d  } |  j  | j d   |  j j d d  } |  j  | j d   d  S(   NR   s   1.1R6   (   R   RK   R   R   R{   R    (   R   t   nested_spant	   last_span(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_next_sibling_may_not_existt  s
    c         C   s$   |  j  |  j j d  d d  d  S(   Nt   spanR   R   (   R   R   t   find_next_sibling(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_next_sibling}  s    c         C   sK   |  j  |  j j d  d d d g  |  j  |  j j d d  d g  d  S(   NR   R   R5   R6   R   (   R   R   t   find_next_siblings(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_next_siblings  s    c         C   s   |  j  d  } | j d d  } |  j | j j d  |  j | j j d  |  j | j d  d g  |  j | j d d  d  |  j | j d d  d   d  S(   Ns   Foo<b>bar</b>bazR$   R.   R   t   bazR-   t   nonesuch(	   R   R    R   R   RF   R   R   R   R{   (   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt"   test_next_sibling_for_text_element  s    (	   R   R   RJ   R   R   R   R   R   R   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR   d  s   							t   TestPreviousSiblingc           B   sG   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s/   t  t |   j   |  j j d d  |  _ d  S(   NR   R6   (   RI   R   RJ   RK   R    R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRJ     s    c         C   s   |  j  |  j j d   d  S(   N(   R   RK   t   previous_siblingR{   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt%   test_previous_sibling_of_root_is_none  s    c         C   sU   |  j  |  j j d d  |  j  |  j j j d d  |  j  |  j j d d  d  S(   NR   R5   R   s   3.1(   R   R   R   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_previous_sibling  s    c         C   sm   |  j  |  j j j d   |  j j d d  } |  j  | j d   |  j j d d  } |  j  | j d   d  S(   NR   s   1.1R4   (   R   RK   R   R   R{   R    (   R   R   t
   first_span(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt#   test_previous_sibling_may_not_exist  s
    c         C   s$   |  j  |  j j d  d d  d  S(   NR   R   R5   (   R   R   t   find_previous_sibling(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_find_previous_sibling  s    c         C   sK   |  j  |  j j d  d d d g  |  j  |  j j d d  d g  d  S(   NR   R5   R   R4   R   (   R   R   t   find_previous_siblings(   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_previous_siblings  s    c         C   s   |  j  d  } | j d d  } |  j | j j d  |  j | j j d  |  j | j d  d g  |  j | j d d  d  |  j | j d d  d   d  S(   Ns   Foo<b>bar</b>bazR$   R   R   R.   R-   R   (	   R   R    R   R   RF   R   R   R   R{   (   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt&   test_previous_sibling_for_text_element  s    (	   R   R   RJ   R   R   R   R   R   R   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR     s   							t   TestTagCreationc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s$   Test the ability to create new tags.c         C   s   |  j  d  } | j d d d d i d d 6} |  j t | t   |  j d | j  |  j t d d d d  | j  |  j d  | j
  d  S(   NR   R9   R-   R   RD   s   a nameRF   (   R   t   new_tagR?   t
   isinstanceR   R   RF   t   dictRD   R{   R   (   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_new_tag  s    ""c         C   s   t  rb t d d  } | j d  } | j d  } |  j d | j    |  j d | j    n  t d d  } | j d  } | j d  } |  j d | j    |  j d | j    d  S(	   NR   s   lxml-xmlt   brt   ps   <br/>s   <p/>s   html.parsers   <p></p>(   t   XML_BUILDER_PRESENTR   R   R   Rc   (   R   t   xml_soupt   xml_brt   xml_pt	   html_soupt   html_brt   html_p(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt1   test_tag_inherits_self_closing_rules_from_builder  s    c         C   sH   |  j  d  } | j d  } |  j d |  |  j t | t   d  S(   NR   R9   (   R   t
   new_stringR   R?   R   R	   (   R   R   t   s(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt'   test_new_string_creates_navigablestring  s    c         C   sK   |  j  d  } | j d t  } |  j d |  |  j t | t   d  S(   NR   R9   (   R   R   R   R   R?   R   (   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt3   test_new_string_can_create_navigablestring_subclass  s    (   R   R   R+   R   R   R   R   (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR     s
   			t   TestTreeModificationc           B   s^  e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! d    Z" d!   Z# d"   Z$ d#   Z% d$   Z& d%   Z' RS(&   c         C   s   |  j  d  } d | j d <|  j | j   |  j d   | j d =|  j | j   |  j d   d | j d <|  j | j   |  j d   d  S(	   Ns   <a id="1"></a>i   R   s   <a id="2"></a>s   <a></a>R9   t   id2s   <a id2="foo"></a>(   R   R)   R   Rd   t   document_for(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_attribute_modification  s    
c         C   s   t  j d    } |  j d d | } t | | d  } t | | d  } d | d <| j j d |  | j j d	 |  |  j | j j   d
  d  S(   NR   s   <body></body>t   builderR)   t   ols   http://foo.com/t   hrefi    i   s4   <body><a href="http://foo.com/"></a><ol></ol></body>(   R   t   lookupR   R   R   t   insertR   Rc   (   R   R   R   R)   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_new_tag_creation  s    
c         C   s   d } |  j  |  } | j d d  } | j } | j d d  j | j  |  j | j |  |  j | j   |  j d   d  S(   NsT   <p id="1">Don't leave me <b>here</b>.</p>
                <p id="2">Don't leave!</p>R   R   sD   <p id="1">Don't leave me .</p>
<p id="2">Don't leave!<b>here</b></p>(   R   R    R   R;   R   R   Rd   R   (   R   t   docR   t   second_parat   bold(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt!   test_append_to_contents_moves_tag  s    	c         C   sD   d } |  j  |  } | j } | j | j  } |  j | |  d  S(   Ns   <a></a><b><c></c></b>(   R   R)   t   replace_withRN   R   (   R   R$   R   R)   t   new_a(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt1   test_replace_with_returns_thing_that_was_replaced  s
    	c         C   s>   d } |  j  |  } | j } | j   } |  j | |  d  S(   Ns   <a><b></b><c></c></a>(   R   R)   t   unwrapR   (   R   R$   R   R)   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt+   test_unwrap_returns_thing_that_was_replaced  s
    	c         C   se   |  j  d  } | j } | j   |  j d  | j  |  j t | j  |  j t | j	 | j
  d  S(   Ns   <a><b>Foo</b></a><c>Bar</c>(   R   R)   t   extractR   R{   R   R   R   R  R  RN   (   R   R   R)   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pytI   test_replace_with_and_unwrap_give_useful_exception_when_tag_has_no_parent  s    	
c         C   sQ   d } |  j  |  } | j } | j j |  |  j | j   |  j |   d  S(   Ns-   <a><b></b><c>Foo<d></d></c></a><a><e></e></a>(   R   RN   R  R   Rd   R   (   R   R$   R   RN   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_replace_tag_with_itself'  s
    	c         C   s5   d } |  j  |  } |  j t | j j | j  d  S(   Ns   <a><b></b></a>(   R   R   R   R   R  R)   (   R   R$   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt1   test_replace_tag_with_its_parent_raises_exception.  s    c         C   s8   d } |  j  |  } |  j t | j j d | j  d  S(   Ns   <a><b></b></a>i    (   R   R   R   R)   R   (   R   R$   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt,   test_insert_tag_into_itself_raises_exception3  s    c   	      C   s   |  j  d  } d } |  j  |  } | j d |  x' | j D] } t | t  s> t  q> Wt | j  \ } } } } |  j d | j	  |  j d | j	  |  j d | j	  |  j d | j	  d S(	   s   Inserting one BeautifulSoup object into another actually inserts all
        of its children -- you'll never combine BeautifulSoup objects.
        s-   <p>And now, a word:</p><p>And we're back.</p>s   <p>p2</p><p>p3</p>i   s   And now, a word:t   p2t   p3s   And we're back.N(
   R   R   t   descendantsR   R   t   AssertionErrort   listt   childrent   assertEqualsR   (	   R   R   R$   t	   to_insertR   t   p1R  R  t   p4(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt1   test_insert_beautifulsoup_object_inserts_children8  s    c         C   sx   |  j  d  } | j } | j d } | j d d  | j \ } } | j d  | j d  |  j d | j j  d  S(   Ns   <p><a>one</a><b>three</b></p>i    i   t   twoR   t   three(   R   R)   R   R   t   replaceWithR   R   R   (   R   R   R)   R   t   leftt   right(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt3   test_replace_with_maintains_next_element_throughoutL  s    	c         C   s   |  j  d  } | j d d  j d  | j d d  } | j } |  j | j |  |  j | j |  |  j | j j |  |  j | j d   d  S(   Ns   <b>Argh!</b>R$   s   Argh!s   Hooray!(	   R   R    R  R   R   R   R   R   R{   (   R   R   t   new_textR   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_replace_final_node[  s    	c         C   s   |  j  d  } | j j d d  |  j | j   |  j d   | j d d  } |  j | j d  |  j | j j |  |  j | j	 d  |  j | j	 j
 |  |  j | j
 d   |  j | j | j  d  S(   Ns   <a><b>Argh!</b><c></c></a>i   s   Hooray!s!   <a><b>Argh!Hooray!</b><c></c></a>R$   s   Argh!(   R   R   R   R   Rd   R   R    R   R   R   R   R{   RN   (   R   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_consecutive_text_nodese  s    
c         C   sr   |  j  d  } | j j d d  | j j d d  |  j d d g | j j  |  j | j j d j d  d  S(   Ns   <a></a>i    R-   R9   (   R   R)   R   R   R   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_insert_stringz  s
    c         C   sW  |  j  } |  j d d | } t | | d  } | j d d  | j j d |  |  j | j   |  j d   | j } |  j | j	 |  |  j | j
 |  | j d d	  } |  j | j |  |  j | j |  | j } |  j | j	 |  |  j | j
 |  | j d d  } |  j | j |  |  j | j |  |  j | j |  d  S(
   Ns%   <a><b>Find</b><c>lady!</c><d></d></a>R   t   magictagi    t   thei   s=   <a><b>Find</b><magictag>the</magictag><c>lady!</c><d></d></a>R$   t   Find(   t   default_builderR   R   R   R)   R   Rd   R   R   R   R   R    R   R   RN   R   (   R   R   R   t	   magic_tagt   b_tagR    t   c_tagR$  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_insert_tag  s,    	
		c         C   sB   d } |  j  |  } | j j | j  |  j | | j    d  S(   Ns   <a><b></b></a>(   R   R)   R;   R   R   Rd   (   R   Rf   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt*   test_append_child_thats_already_at_the_end  s    c         C   sE   d } |  j  |  } | j j d | j  |  j d | j    d  S(   Ns   <a><b></b><c></c><d></d></a>i    s   <a><d></d><b></b><c></c></a>(   R   R)   R   t   dR   Rd   (   R   Rf   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt$   test_move_tag_to_beginning_of_parent  s    c         C   s?   |  j  d  } | j j d d  |  j t | j  d  d  S(   Ns   <br/>i   t   Contentss   <br>Contents</br>(   R   R   R   R   R#   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt&   test_insert_works_on_empty_element_tag  s    c         C   s   |  j  d  } | j j d  | j j d  |  j | j   |  j d   | j j | j  |  j | j   |  j d   d  S(   Ns   <a>foo</a><b>bar</b>t   BAZt   QUUXs   QUUX<a>foo</a>BAZ<b>bar</b>s   QUUX<b>bar</b><a>foo</a>BAZ(   R   R   t   insert_beforeR)   R   Rd   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_insert_before  s    c         C   s   |  j  d  } | j j d  | j j d  |  j | j   |  j d   | j j | j  |  j | j   |  j d   d  S(   Ns   <a>foo</a><b>bar</b>R0  R1  s   <a>foo</a>QUUX<b>bar</b>BAZs   QUUX<b>bar</b><a>foo</a>BAZ(   R   R   t   insert_afterR)   R   Rd   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_insert_after  s    c         C   ss   |  j  d  } | j d  } | j d  } |  j t | j |  |  j t | j |  |  j t | j |  d  S(   NR   R)   (   R   R   R   R   R   R4  t   NotImplementedError(   R   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt:   test_insert_after_raises_exception_if_after_has_no_meaning  s    c         C   ss   |  j  d  } | j d  } | j d  } |  j t | j |  |  j t | j |  |  j t | j |  d  S(   NR   R)   (   R   R   R   R   R   R2  R6  (   R   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pytF   test_insert_before_raises_notimplementederror_if_before_has_no_meaning  s    c         C   s   |  j  d  } | j d  \ } } | j |  |  j | j   |  j d   |  j | j d   |  j | j | j  |  j | j	 d  |  j | j
 d  d  S(   Ns;   <p>There's <b>no</b> business like <b>show</b> business</p>R   s0   <p>There's  business like <b>no</b> business</p>t   nos	    business(   R   R'   R  R   Rd   R   R   R{   R   R   R   (   R   R   R9  t   show(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_replace_with  s    		
c         C   sB   d } |  j  |  } | j j | j  |  j d | j    d  S(   Ns   <a><b></b><c></c></a>s   <a><c></c></a>(   R   R   R  RN   R   Rd   (   R   Rf   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_replace_first_child  s    c         C   sB   d } |  j  |  } | j j | j  |  j d | j    d  S(   Ns   <a><b></b><c></c></a>s   <a><b></b></a>(   R   RN   R  R   R   Rd   (   R   Rf   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_replace_last_child  s    c         C   sx  |  j  d  } | j } | j } | j |  |  j | j   |  j d   |  j | j d   |  j | j	 d d  j
 d   |  j | j d   |  j | j d   |  j | j d   |  j | j | j  |  j | j d  |  j | j
 j
 | j  |  j | j d   | j	 d d  } | j } |  j | j
 |  |  j | j |  |  j | j |  |  j | j |  d  S(   NsQ   <a>We<b>reserve<c>the</c><d>right</d></b></a><e>to<f>refuse</f><g>service</g></e>s-   <a>We<f>refuse</f></a><e>to<g>service</g></e>R$   R  t   Wet   to(   R   R   Rp   R  R   Rd   R   R   R{   R    R   R   R   R   R)   t   et   g(   R   R   t
   remove_tagt   move_tagt   to_textt   g_tag(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_nested_tag_replace_with  s.    			
	c         C   sI   |  j  d  } | j j   |  j | j d   |  j | j j d  d  S(   NsI   
            <p>Unneeded <em>formatting</em> is unneeded</p>
            s   Unneeded formatting is unneeded(   R   t   emR  R   R{   R   R$   (   R   RK   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_unwrap  s
    	c         C   sc   |  j  d  } | j j | j d   } |  j | j   d  |  j | j   |  j d   d  S(   Ns   I wish I was bold.R   s   <b>I wish I was bold.</b>(   R   R   t   wrapR   R   Rd   R   (   R   R   Rs   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt	   test_wrap"  s
    c         C   sH   |  j  d  } | j j j | j  |  j | j   |  j d   d  S(   Ns   <b></b>I wish I was bold.s   <b>I wish I was bold.</b>(   R   R   R   RI  R   Rd   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt%   test_wrap_extracts_tag_from_elsewhere)  s    c         C   sd   |  j  d  } | j j j | j  |  j d t | j j   |  j | j   |  j d   d  S(   Ns+   <b>I like being bold.</b>I wish I was bold.i   s+   <b>I like being bold.I wish I was bold.</b>(	   R   R   R   RI  R   R&   R   Rd   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt&   test_wrap_puts_new_contents_at_the_end/  s    c         C   s;  |  j  d  } |  j t | j j  d  | j d d  j   } |  j | j   d  |  j | j   d  |  j t | j j  d  |  j | j d   |  j | j
 d   |  j | j j d   | j d d	  } | j d d
  } |  j | j |  |  j | j |  |  j | j
 |  |  j | j |  d  S(   NsR   <html><body>Some content. <div id="nav">Nav crap</div> More content.</body></html>i   R   t   navs6   <html><body>Some content.  More content.</body></html>s   <div id="nav">Nav crap</div>i   R$   s   Some content. s    More content.(   R   R   R&   R   R   R    R	  Rd   R   R{   R   R   R   R   (   R   R   t	   extractedt	   content_1t	   content_2(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_extract7  s"    	c         C   s   |  j  d  } | j j } | j j } | j d  } | j d  } | j j |  | j j |  | j   | j   |  j | | j j  |  j | | j j  d  S(   Ns   <a>foo</a><b>bar</b>R9   R-   (   R   R)   R   R   R   R;   R	  R   (   R   R   t   foo_1t   bar_1t   foo_2t   bar_2(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt4   test_extract_distinguishes_between_identical_stringsP  s    

c         C   sU   |  j  d  } g  | j d  D] } | j j   ^ q |  j d t | j   d  S(   Nsv   
<html>
<head>
<script>foo</script>
</head>
<body>
 <script>bar</script>
 <a></a>
</body>
<script>baz</script>
</html>t   scripts   <body>

<a></a>
</body>(   R   R'   RW  R	  R   t   unicodeR   (   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt"   test_extract_multiples_of_same_taga  s    
	)c         C   s?   |  j  d  } | j d  j   |  j d  | j d   d  S(   Ns   <html>
<body>hi</body>
</html>R   (   R   R    R	  R   R{   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pytB   test_extract_works_when_element_is_surrounded_by_identical_stringsq  s    	c         C   s   |  j  d  } | j } | j j   |  j t | j j  d  |  j t | d   | j	 } | j d t
  |  j d t | j   d S(   s   Tag.clear()s4   <p><a>String <em>Italicized</em></a> and another</p>i    R   t	   decomposeN(   R   R)   R   t   clearR   R&   R   R?   R@   RG  R1   (   R   R   R)   RG  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt
   test_clearz  s    		c         C   s]   |  j  d  } d | j _ |  j | j j d g  d | j _ |  j | j j d g  d S(   s   Tag.string = 'string's   <a></a> <b><c></c></b>R9   R-   N(   R   R)   R   R   R   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_string_set  s
    c         C   s>   |  j  d  } | j j | j _ |  j | j j   d  d  S(   Ns   <a><b>foo</b><c>bar</c>s   <a><b>bar</b><c>bar</c></a>(   R   RN   R   R   R   R)   Rc   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt/   test_string_set_does_not_affect_original_string  s    c         C   sG   |  j  d  } t d  } | | j _ |  j t | j j t   d  S(   Ns   <a></a>R9   (   R   R   R)   R   R?   R   (   R   R   t   cdata(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt)   test_set_string_preserves_class_of_string  s    ((   R   R   R   R   R  R  R  R
  R  R  R  R  R  R   R!  R"  R*  R+  R-  R/  R3  R5  R7  R8  R;  R<  R=  RF  RH  RJ  RK  RL  RQ  RV  RY  RZ  R]  R^  R_  Ra  (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR     sL   													
										
						$												t   TestElementObjectsc           B   s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z RS(   s)   Test various features of element objects.c         C   sw   |  j  d  } |  j t | j  d  |  j t |  d  |  j t | j  d  |  j t | j j  d  d S(   s3   The length of an element is its number of children.s   <top>1<b>2</b>3</top>i   i   N(   R   R   R&   R   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_len  s
    c         C   sj   |  j  d  } |  j | j | j d   |  j | j j | j d  j d   |  j | j d  d S(   s2   Accessing a Python member .foo invokes find('foo')s   <b><i></i></b>R   R   N(   R   R   R   R    R   R)   R{   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_member_access_invokes_find  s    (c         C   sg   |  j  d  } t j d t   } | j } Wd  QX|  j | j |  |  j d t | d j   d  S(   Ns   <b><i></i></b>t   recordsp   .bTag is deprecated, use .find("b") instead. If you really were looking for a tag called bTag, use .find("bTag")i    (	   R   t   warningst   catch_warningsR1   t   bTagR   R   R#   t   message(   R   R   t   wR   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_deprecated_member_access  s    c         C   sE   |  j  d  } |  j | j j d   |  j | j j d   d S(   s   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.
        s   <foo attr='bar'>t   attrt   attr2N(   R   R?   R9   t   has_attrt   assertFalse(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_has_attr  s    c         C   s   d } |  j  | d  d  S(   Ns%   <b a="1" z="5" m="3" f="2" y="4"></b>s%   <b a="1" f="2" m="3" y="4" z="5"></b>(   t   assertSoupEquals(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt.   test_attributes_come_out_in_alphabetical_order  s    c         C   s)   |  j  d  } |  j | j j d  d  S(   Ns
   <b>foo</b>R9   (   R   R   R   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_string  s    c         C   s)   |  j  d  } |  j | j j d   d  S(   Ns   <b></b>(   R   R   R   R   R{   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_empty_tag_has_no_string  s    c         C   s   |  j  d  } |  j | j j d   |  j  d  } |  j | j j d   |  j  d  } | j j d d  |  j | j j d   d  S(   Ns   <a>foo<b></b><b></b></b>s   <a>foo<b></b>bar</b>s
   <a>foo</b>i   R-   (   R   R   R   R   R{   R)   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt-   test_tag_with_multiple_children_has_no_string  s    c         C   s<   |  j  d  } |  j | j j d  |  j | j d  d  S(   Ns   <a><b>foo</b></a>R9   (   R   R   R)   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt)   test_tag_with_recursive_string_has_string  s    c         C   sH   |  j  d  } |  j | j j  |  j  d  } |  j | j j  d S(   s7   Only a tag containing a single text node has a .string.s   <b>f<i>e</i>o</b>s   <b></b>N(   R   Ro  R   R   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_lack_of_string  s    c         C   s   |  j  d  } |  j | j j d  |  j | j j d t  d  |  j | j j d  d  |  j | j j d d t d  d S(	   sB   Tag.text and Tag.get_text(sep=u"") -> all child text, concatenateds   <a>a<b>r</b>   <r> t </r></a>s   ar  t t   stript   artt   ,s	   a,r, , t s   a,r,tN(   R   R   R)   R$   t   get_textR1   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_all_text  s
    c         C   sg   |  j  d  } |  j | j   d  |  j | j d t t f  d  |  j | j d d   d  d  S(   Ns   foo<!--IGNORE-->bart   foobart   typest   fooIGNOREbar(   R   R   R{  R	   R   R{   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_get_text_ignores_comments  s    c         C   s2   |  j  d  } |  j d d g t | j   d  S(   Ns   foo<!--IGNORE-->barR9   R-   (   R   R   R  t   strings(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt!   test_all_strings_ignores_comments  s    (   R   R   R+   Rc  Rd  Rk  Rp  Rr  Rs  Rt  Ru  Rv  Rw  R|  R  R  (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRb    s   														t   TestCDAtaListAttributesc           B   sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   s0   Testing cdata-list attributes like 'class'.
    c         C   s-   |  j  d  } |  j d g | j d  d  S(   Ns   <a class='foo'>R9   Rj   (   R   R   R)   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_single_value_becomes_list  s    c         C   s0   |  j  d  } |  j d d g | j d  d  S(   Ns   <a class='foo bar'>R9   R-   Rj   (   R   R   R)   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt!   test_multiple_values_becomes_list  s    c         C   s3   |  j  d  } |  j d d d g | j d  d  S(   Ns   <a class='foo	bar
baz'>R9   R-   R   Rj   (   R   R   R)   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt2   test_multiple_values_separated_by_weird_whitespace  s    c         C   s,   |  j  d  } |  j d | j j    d  S(   Ns   <a class='foo	bar'>s   <a class="foo bar"></a>(   R   R   R)   Rc   (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt,   test_attributes_joined_into_string_on_output  s    c         C   s2   |  j  d  } |  j d g | j j d   d  S(   Ns   <a id='abc def'>s   abc defR   (   R   R   R)   t   get_attribute_list(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_get_attribute_list  s    c         C   s0   |  j  d  } |  j d d g | j d  d  S(   Ns(   <form accept-charset="ISO-8859-1 UTF-8">s
   ISO-8859-1s   UTF-8s   accept-charset(   R   R   t   form(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_accept_charset!  s    c         C   s0   d } |  j  |  } |  j d | j d  d  S(   Ns)   <a accept-charset="ISO-8859-1 UTF-8"></a>s   ISO-8859-1 UTF-8s   accept-charset(   R   R   R)   (   R   Rf   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt-   test_cdata_attribute_applying_only_to_one_tag%  s    c            sH   |  j  d  j   |  j d    j    f d   } |  j t |  d  S(   NR   c              s   d   _  d  S(   NR9   (   RF   (    (   R   (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   t0  s    (   R   R   R   R{   RF   R   t   AttributeError(   R   R  (    (   R   s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt'   test_string_has_immutable_name_property-  s    (   R   R   R+   R  R  R  R  R  R  R  R  (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR  	  s   							t   TestPersistencec           B   s_   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(
   s*   Testing features like pickle and deepcopy.c         C   s5   t  t |   j   d |  _ |  j |  j  |  _ d  S(   Nsy  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Beautiful Soup: We called him Tortoise because he taught us.</title>
<link rev="made" href="mailto:leonardr@segfault.org">
<meta name="Description" content="Beautiful Soup: an HTML parser optimized for screen-scraping.">
<meta name="generator" content="Markov Approximation 1.4 (module: leonardr)">
<meta name="author" content="Leonard Richardson">
</head>
<body>
<a href="foo">foo</a>
<a href="foo"><b>bar</b></a>
</body>
</html>(   RI   R  RJ   t   pageR   RK   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRJ   7  s    	c         C   sZ   t  j |  j d  } t  j |  } |  j | j t  |  j | j   |  j j    d  S(   Ni   (   t   picklet   dumpsRK   t   loadsR   t	   __class__R   Rd   (   R   t   dumpedt   loaded(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt!   test_pickle_and_unpickle_identityK  s    c         C   s5   t  j |  j  } |  j | j   |  j j    d  S(   N(   t   copyt   deepcopyRK   R   Rd   (   R   t   copied(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_deepcopy_identityS  s    c         C   sQ   t  d d  } | j } | j   } |  j d t |   |  j | | j  d  S(   Ns   <p>&nbsp;</p>s   html.parseru	   <p> </p>(   R   t   original_encodingt   __copy__R   RX  (   R   R   t   encodingR  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_copy_preserves_encodingX  s
    	c         C   sY   d } |  j  |  } t j | t j  } t j |  } |  j | j   | j    d  S(   Nu
   <b>☃</b>(   R   R  R  t   HIGHEST_PROTOCOLR  R   Rd   (   R   R   R   R  R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_unicode_pickle_  s
    c         C   s   d } |  j  |  } | j d d  } t j |  } |  j | |  |  j d  | j  |  j d  | j  |  j d  | j  |  j d  | j  |  j d  | j	  d  S(   Nu   <b>Foo<a></a></b><b>Bar</b>R   R.   (
   R   R    R  R   R{   R   R   t   assertNotEqualR   R   (   R   R   R   t   s1t   s2(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt1   test_copy_navigablestring_is_not_attached_to_treeg  s    c         C   sW   d } |  j  |  } | j } t j |  } |  j | |  |  j t | t   d  S(   Nu   <b><!--Foo--></b>(   R   R   R  R   R?   R   R   (   R   R   R   R  R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt0   test_copy_navigablestring_subclass_has_same_types  s    	c         C   s8   d } |  j  |  } t j |  } |  j | |  d  S(   Nu)   <div><b>Foo<a></a></b><b>Bar</b></div>end(   R   R  R   (   R   R   R   t	   soup_copy(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_copy_entire_soup{  s    c         C   s   d } |  j  |  } | j } t j |  } |  j t |  t |   |  j | |  |  j | | k  |  j d  | j  |  j d  | j  |  j d  | j	 d d  j
  |  j d  | j	 d d  j
  d  S(   Nu)   <div><b>Foo<a></a></b><b>Bar</b></div>endR   t   Bar(   R   RX   R  R   RX  Ro  R{   R   R   R    R   R  (   R   R   R   RX   t   div_copy(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_copy_tag_copies_contents  s    	(   R   R   R+   RJ   R  R  R  R  R  R  R  R  (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR  4  s   								t   TestSubstitutionsc           B   s   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   sD   d } |  j  |  } | j d d  } |  j | |  j d   d  S(   Nu#   <b>&lt;&lt;Sacré bleu!&gt;&gt;</b>t	   formattert   minimal(   R   Rd   R   R   (   R   R   R   t   decoded(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt!   test_default_formatter_is_minimal  s    c         C   sD   d } |  j  |  } | j d d  } |  j | |  j d   d  S(   Nu'   <br><b>&lt;&lt;Sacré bleu!&gt;&gt;</b>R  R   s.   <br/><b>&lt;&lt;Sacr&eacute; bleu!&gt;&gt;</b>(   R   Rd   R   R   (   R   R   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_formatter_html  s    c         C   sD   d } |  j  |  } | j d d  } |  j | |  j d   d  S(   Nu'   <br><b>&lt;&lt;Sacré bleu!&gt;&gt;</b>R  t   html5s-   <br><b>&lt;&lt;Sacr&eacute; bleu!&gt;&gt;</b>(   R   Rd   R   R   (   R   R   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_formatter_html5  s    c         C   sD   d } |  j  |  } | j d d  } |  j | |  j d   d  S(   Nu#   <b>&lt;&lt;Sacré bleu!&gt;&gt;</b>R  R  (   R   Rd   R   R   (   R   R   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_formatter_minimal  s    c         C   sD   d } |  j  |  } | j d d   } |  j | |  j d   d  S(   Nu#   <b>&lt;&lt;Sacré bleu!&gt;&gt;</b>R  u   <b><<Sacré bleu!>></b>(   R   Rd   R{   R   R   (   R   R   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_formatter_null  s
    	c         C   sG   d } |  j  |  } | j d d    } |  j | |  j d   d  S(   Nu!   <b>&lt;foo&gt;</b><b>bar</b><br/>R  c         S   s
   |  j    S(   N(   t   upper(   t   x(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   <lambda>  s    u   <b><FOO></b><b>BAR</b><br>(   R   Rd   R   R   (   R   R   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_formatter_custom  s    c         C   s   d } |  j  |  } | j } d } |  j | | j    |  j | | j d d   d } |  j | | j d d   |  j | | j d d    d } |  j | | j d d     d  S(	   Nu%   <a href="http://a.com?a=b&c=é">e</a>u)   <a href="http://a.com?a=b&amp;c=é">e</a>R  R  u/   <a href="http://a.com?a=b&amp;c=&eacute;">e</a>R   u%   <a href="HTTP://A.COM?A=B&C=É">E</a>c         S   s
   |  j    S(   N(   R  (   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR    s    (   R   R)   R   Rd   R{   (   R   R   R   R)   t   expect_minimalt   expect_htmlt   expect_upper(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt)   test_formatter_is_run_on_attribute_values  s    	c         C   s2   d } t  | d  j   } |  j d | k  d  S(   NsO   
  <script type="text/javascript">
   console.log("< < hey > > ");
  </script>
s   html.parsers   < < hey > >(   R   Rc   R?   (   R   R   t   encoded(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt2   test_formatter_skips_script_tag_for_html_documents  s    c         C   s2   d } t  | d  j   } |  j d | k  d  S(   NsF   
  <style type="text/css">
   console.log("< < hey > > ");
  </style>
s   html.parsers   < < hey > >(   R   Rc   R?   (   R   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt1   test_formatter_skips_style_tag_for_html_documents  s    c         C   s,   |  j  d  } |  j d | j j    d  S(   Ns*   <div>  foo  <pre>  	bar
  
  </pre>  baz  u/   <div>
 foo
 <pre>  	bar
  
  </pre>
 baz
</div>(   R   R   RX   t   prettify(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt,   test_prettify_leaves_preformatted_text_alone  s    c         C   s;   t  d d  } | j d d    } |  j d | k  d  S(   Ns   <html><body>foo</body></html>s   html.parserR  c         S   s
   |  j    S(   N(   R  (   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR    s    t   FOO(   R   R  R?   (   R   R   t   pretty(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt(   test_prettify_accepts_formatter_function  s    c         C   s/   |  j  d  } |  j t t | j     d  S(   Ns   <a></a>(   R   R   RX  t   typeR  (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt(   test_prettify_outputs_unicode_by_default  s    c         C   s2   |  j  d  } |  j t t | j d    d  S(   Ns   <a></a>s   utf-8(   R   R   t   bytesR  R  (   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_prettify_can_encode_data  s    c         C   sD   d } |  j  |  } | j j d  } |  j | | j d   d  S(   Nu   <b>Sacré bleu!</b>s   utf-8(   R   R   Rc   R   (   R   R   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt,   test_html_entity_substitution_off_by_default  s    c         C   s   d } |  j  |  } |  j | j d d  | j d  } |  j d | k  | j d  } |  j d | k  | j d  } |  j d	 | k  | j d
  j d
  } |  j d | k  d  S(   NsE   <meta content="text/html; charset=x-sjis" http-equiv="Content-type"/>t   contents   text/html; charset=x-sjiss   utf-8s   charset=utf-8t   euc_jps   charset=euc_jps	   shift-jiss   charset=shift-jiss   utf-16s   charset=utf-16(   R   R   t   metaRc   R?   Rd   (   R   t   meta_tagR   t   utf_8R  t	   shift_jist   utf_16_u(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_encoding_substitution  s    c         C   sE   d } t  d  } |  j | d | } |  j | j d j d  d  S(   Ns`   <head><meta content="text/html; charset=x-sjis" http-equiv="Content-type"/></head><pre>foo</pre>t   pret
   parse_onlyi    (   R
   R   R   R   RF   (   R   R   Ry   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt;   test_encoding_substitution_doesnt_happen_if_tag_is_strained$  s    (   R   R   R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR    s    	
			
			
											t   TestEncodingc           B   sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   s0   Test the ability to encode objects into strings.c         C   sA   d } |  j  |  } |  j | j j j d  d j d   d  S(   Nu
   <b>☃</b>s   utf-8u   ☃(   R   R   R   R   Rc   (   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt"   test_unicode_string_can_be_encoded2  s    c         C   s>   d } |  j  |  } |  j | j j d  | j d   d  S(   Nu
   <b>☃</b>s   utf-8(   R   R   R   Rc   (   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt1   test_tag_containing_unicode_string_can_be_encoded8  s    c         C   s5   d } |  j  |  } |  j | j j d  d  d  S(   Nu
   <b>☃</b>t   asciis   <b>&#9731;</b>(   R   R   R   Rc   (   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt<   test_encoding_substitutes_unrecognized_characters_by_default>  s    c         C   s5   d } |  j  |  } |  j t | j d d d d  S(   Nu
   <b>☃</b>R  t   errorst   strict(   R   R   t   UnicodeEncodeErrorRc   (   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt    test_encoding_can_be_made_strictC  s    c         C   s2   d } |  j  |  } |  j d | j j    d  S(   Nu
   <b>☃</b>u   ☃(   R   R   R   t   decode_contents(   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_decode_contentsI  s    c         C   sA   d } |  j  |  } |  j d j d  | j j d d   d  S(   Nu
   <b>☃</b>u   ☃Ra   R  (   R   R   Rc   R   t   encode_contents(   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_encode_contentsN  s
    c         C   s;   d } |  j  |  } |  j d j d  | j j    d  S(   Nu
   <b>☃</b>u   ☃Ra   (   R   R   Rc   R   t   renderContents(   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_deprecated_renderContentsU  s    c         C   sN   d } |  j  |  } t r4 |  j | t |   n |  j d t |   d  S(   Nu
   <b>☃</b>s   <b>\u2603</b>(   R   R   R   t   repr(   R   R   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt	   test_repr[  s
    (   R   R   R+   R  R  R  R  R  R  R  R  (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR  /  s   							t   TestNavigableStringSubclassesc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   sx   |  j  d  } t d  } | j d |  |  j t |  d  |  j | j d d  d  |  j | j d d  d  S(   NR   R9   i   s   <![CDATA[foo]]>R$   i    (   R   R   R   R   R#   R    R   (   R   R   R`  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt
   test_cdatae  s    c            sv   d   _    f d   }   j d  } t d  } | j d |    j d | j d |     j d   j   d S(	   sk   Text inside a CData object is passed into the formatter.

        But the return value is ignored.
        i    c             s     j  d 7_  d S(   Ni   s   BITTER FAILURE(   t   count(   t   args(   R   (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt	   incrementv  s    R   s   <><><>i   s   <![CDATA[<><><>]]>R  N(   R  R   R   R   R   Rc   (   R   R  R   R`  (    (   R   s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_cdata_is_never_formattedo  s    	c         C   sE   t  d  } |  j d  } | j d |  |  j | j   d  d  S(   NR9   R   i   s   <!DOCTYPE foo>
(   R   R   R   R   Rc   (   R   t   doctypeR   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_doctype_ends_in_newline  s    c         C   s&   t  d  } |  j d | j    d  S(   NR9   s   <?foo?>(   R   R   t   output_ready(   R   R,  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_declaration  s    (   R   R   R  R  R  R  (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR  c  s   	
		t   TestSoupSelectorc           B   s  e  Z d  Z d   Z d   Z e Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! d   Z" d    Z# d!   Z$ d"   Z% d#   Z& d$   Z' d%   Z( d&   Z) d'   Z* d(   Z+ d)   Z, d*   Z- d+   Z. d,   Z/ d-   Z0 d.   Z1 d/   Z2 d0   Z3 d1   Z4 d2   Z5 d3   Z6 d4   Z7 d5   Z8 d6   Z9 d7   Z: d8   Z; d9   Z< RS(:   s  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>The title</title>
<link rel="stylesheet" href="blah.css" type="text/css" id="l1">
</head>
<body>
<custom-dashed-tag class="dashed" id="dash1">Hello there.</custom-dashed-tag>
<div id="main" class="fancy">
<div id="inner">
<h1 id="header1">An H1</h1>
<p>Some text</p>
<p class="onep" id="p1">Some more text</p>
<h2 id="header2">An H2</h2>
<p class="class1 class2 class3" id="pmulti">Another</p>
<a href="http://bob.example.org/" rel="friend met" id="bob">Bob</a>
<h2 id="header3">Another H2</h2>
<a id="me" href="http://simonwillison.net/" rel="me">me</a>
<span class="s1">
<a href="#" id="s1a1">span1a1</a>
<a href="#" id="s1a2">span1a2 <span id="s1a2s1">test</span></a>
<span class="span2">
<a href="#" id="s2a1">span2a1</a>
</span>
<span class="span3"></span>
<custom-dashed-tag class="dashed" id="dash2"/>
<div data-tag="dashedvalue" id="data1"/>
</span>
</div>
<x id="xid">
<z id="zida"/>
<z id="zidab"/>
<z id="zidac"/>
</x>
<y id="yid">
<z id="zidb"/>
</y>
<p lang="en" id="lang-en">English</p>
<p lang="en-gb" id="lang-en-gb">English UK</p>
<p lang="en-us" id="lang-en-us">English US</p>
<p lang="fr" id="lang-fr">French</p>
</div>

<div id="footer">
</div>
c         C   s   t  |  j d  |  _ d  S(   Ns   html.parser(   R   t   HTMLR   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyRJ     s    c         K   sv   g  |  j  j | |  D] } | d ^ q } | j   | j   |  j | | d | d j |  d j |  f  d  S(   NR   s$   Selector %s, expected [%s], got [%s]s   , (   R   t   selectt   sortR   t   join(   R   t   selectort   expected_idst   kwargst   elt   el_ids(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR     s    ,

c         G   s+   x$ | D] \ } } |  j  | |  q Wd  S(   N(   t   assertSelect(   R   t   testsR  R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   assertSelectMultiple  s    c         C   s]   |  j  j d  } |  j t |  d  |  j | d j d  |  j | d j d g  d  S(   NRb   i   i    u	   The title(   R   R  R   R&   RF   R   (   R   t   els(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_one_tag_one  s    c         C   sv   |  j  j d  } |  j t |  d  x! | D] } |  j | j d  q/ W|  j  j d  } |  j d | d  d  S(   NRX   i   t   mainR   (   R   R  R   R&   RF   t
   select_one(   R   R  RX   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_one_tag_many  s    c         C   s&   |  j  j d  } |  j d  |  d  S(   Nt   nonexistenttag(   R   R  R   R{   (   R   t   match(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt(   test_select_one_returns_none_if_no_match  s    c         C   s,   |  j  j d  } |  j d d d g  d  S(   Ns   div divt   innert   data1(   R   R  R   (   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_tag_in_tag_one  s    c         C   s1   x* d D]" } |  j  | d d d d g  q Wd  S(	   Ns   html divs   html body divs   body divR  R  R  t   footer(   s   html divs   html body divs   body div(   R   (   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_tag_in_tag_many  s    c         C   s[   |  j  d d g d d |  j  d d d g d d |  j  d d	 d d d
 g d d d  S(   Ns   html divR  R3   i   s   html body divR  i   s   body divR  R
  i
   (   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt
   test_limit  s    c         C   s&   |  j  t |  j j d   d  d  S(   Nt   deli    (   R   R&   R   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_tag_no_match  s    c         C   s   |  j  t |  j j d  d  S(   Ns   tag%t(   R   R   R   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_invalid_tag  s    c         C   s   |  j  d d d g  d  S(   Ns   custom-dashed-tagt   dash1t   dash2(   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_select_dashed_tag_ids  s    c         C   sE   |  j  j d  } |  j | d j d  |  j | d d d  d  S(   Ns   custom-dashed-tag[id="dash2"]i    s   custom-dashed-tagR   R  (   R   R  R   RF   (   R   t   dashed(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_select_dashed_by_id  s    c         C   s'   |  j  |  j j d  d j d  d  S(   Ns   body > custom-dashed-tagi    u   Hello there.(   R   R   R  R$   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_dashed_tag_text  s    c         C   s,   |  j  |  j j d  |  j j d   d  S(   Ns   custom-dashed-tag(   R   R   R  R'   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt#   test_select_dashed_matches_find_all  s    c         C   s)   |  j  d d g f d d d g f  d  S(   Nt   h1t   header1t   h2t   header2t   header3(   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_header_tags
  s    c         C   so   xh d	 D]` } |  j  j |  } |  j t |  d  |  j | d j d  |  j | d d d g  q Wd  S(
   Ns   .oneps   p.oneps   html p.onepi   i    R   Rj   t   onep(   s   .oneps   p.oneps   html p.onep(   R   R  R   R&   RF   (   R   R  R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_class_one  s
    c         C   s,   |  j  j d  } |  j t |  d  d  S(   Ns   div.onepi    (   R   R  R   R&   (   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_class_mismatched_tag  s    c         C   s(   x! d D] } |  j  | d g  q Wd  S(   Ns	   div#inners   #inners   div div#innerR  (   s	   div#inners   #inners   div div#inner(   R   (   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_one_id  s    c         C   s,   |  j  j d  } |  j t |  d  d  S(   Ns   #doesnotexisti    (   R   R  R   R&   (   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_bad_id  s    c         C   s   |  j  j d  } |  j t |  d  x! | D] } |  j | j d  q/ W|  j | d d d g  |  j | d j d   d  S(   Ns   div#inner pi   R   i   Rj   R  i    (   R   R  R   R&   RF   Ro  Rn  (   R   R  R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_items_in_id#  s    c         C   s7   x0 d D]( } |  j  t |  j j |   d  q Wd  S(   Ns   div#main dels   div#main div.oopss   div div#maini    (   s   div#main dels   div#main div.oopss   div div#main(   R   R&   R   R  (   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_a_bunch_of_emptys+  s    c         C   s(   x! d
 D] } |  j  | d	 g  q Wd  S(   Ns   .class1s   p.class1s   .class2s   p.class2s   .class3s   p.class3s   html p.class2s   div#inner .class2t   pmulti(   s   .class1s   p.class1s   .class2s   p.class2s   .class3s   p.class3s   html p.class2s   div#inner .class2(   R   (   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_multi_class_support/  s    
c         C   s(   x! d D] } |  j  | d g  q Wd  S(   Ns   .class1.class3s   .class3.class2s   .class1.class2.class3R$  (   s   .class1.class3s   .class3.class2s   .class1.class2.class3(   R   (   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_multi_class_selection4  s    
c         C   s-   |  j  d d d g  |  j  d d g  d  S(   Ns   .s1 > at   s1a1t   s1a2s   .s1 > a spant   s1a2s1(   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_child_selector9  s    c         C   s   |  j  d d g  d  S(   Ns   .s1 > a#s1a2 spanR)  (   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_child_selector_id=  s    c         C   s   |  j  d d g f d d g f d d g f d d g f d d g f d d g f d	 d g f d
 g  f d d g f d d g f d d g f d g  f d g  f d g  f  d  S(   Ns   p[class="onep"]R  s
   p[id="p1"]s   [class="onep"]s	   [id="p1"]s   link[rel="stylesheet"]t   l1s   link[type="text/css"]s   link[href="blah.css"]s   link[href="no-blah.css"]s   [rel="stylesheet"]s   [type="text/css"]s   [href="blah.css"]s   [href="no-blah.css"]s   p[href="no-blah.css"](   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_attribute_equals@  s    			c         C   s   |  j  d d g f d d g f d d g f d d g f d d g f d d g f d d	 g f d
 d	 g f d d	 g f d d	 g f 
 d  S(   Ns   p[class~="class1"]R$  s   p[class~="class2"]s   p[class~="class3"]s   [class~="class1"]s   [class~="class2"]s   [class~="class3"]s   a[rel~="friend"]t   bobs   a[rel~="met"]s   [rel~="friend"]s   [rel~="met"](   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_attribute_tildeR  s    c         C   s   |  j  d d g f d d g f d g  f d g  f d g  f d d g f d d	 d
 g f d d	 d
 g f d d d g f d d
 d g f d d g f d d
 g f d d g f  d  S(   Ns   [rel^="style"]R,  s   link[rel^="style"]s   notlink[rel^="notstyle"]s   [rel^="notstyle"]s   link[rel^="notstyle"]s   link[href^="bla"]s   a[href^="http://"]R.  t   mes   [href^="http://"]s	   [id^="p"]R$  R  s	   [id^="m"]R  s   div[id^="m"]s
   a[id^="m"]s   div[data-tag^="dashed"]R  (   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_attribute_startswith`  s    			c         C   sh   |  j  d d g f d d g f d d g f d d d d d d	 d
 d d g f d d g f d g  f  d  S(   Ns   [href$=".css"]R,  s   link[href$=".css"]s   link[id$="1"]s	   [id$="1"]R  R  R  R'  t   s2a1R)  R  s   div[id$="1"]s   [id$="noending"](   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_attribute_endswithq  s    !c         C   s4  |  j  d d g f d d g f d g  f d g  f d g  f d d g f d d	 d
 g f d d d g f d d g f d d
 g f d d g f d d g f d d g f d d d d d d d d d d g	 f d d g f d g  f d d	 d
 d g f d d	 d
 g f d  d g f d! d d" g f d# d" g f d$ d g f  d  S(%   Ns   [rel*="style"]R,  s   link[rel*="style"]s   notlink[rel*="notstyle"]s   [rel*="notstyle"]s   link[rel*="notstyle"]s   link[href*="bla"]s   [href*="http://"]R.  R0  s	   [id*="p"]R$  R  s   div[id*="m"]R  s
   a[id*="m"]s   [href*=".css"]s   link[href*=".css"]s   link[id*="1"]s	   [id*="1"]R  R  R'  R(  R2  R)  R  s   div[id*="1"]s   [id*="noending"]s   [href*="."]s   a[href*="."]s   link[href*="."]s   div[id*="n"]R  s   div[id*="nn"]s   div[data-tag*="edval"](   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_attribute_contains{  s.    			$	c         C   sG   |  j  d d d d g f d d d d g f d d g f d g  f  d  S(	   Ns   p[lang|="en"]s   lang-ens
   lang-en-gbs
   lang-en-uss   [lang|="en"]s   p[lang|="fr"]s   lang-frs   p[lang|="gb"](   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_attribute_exact_or_hypen  s
    c      
   C   s}   |  j  d d d d g f d d g f d d d g f d d d	 d
 d g f d d d g f d g  f d g  f d d g f  d  S(   Ns   [rel]R,  R.  R0  s	   link[rel]s   a[rel]s   [lang]s   lang-ens
   lang-en-gbs
   lang-en-uss   lang-frs   p[class]R  R$  s   [blah]s   p[blah]s   div[data-tag]R  (   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_attribute_exists  s    		c         C   s>   d } t  | d  } | j d  \ } |  j d | j  d  S(   Ns]   <div style="display: wrong">nope</div>
        <div style="display: right">yes</div>
        s   html.parsers   div[style="display: right"]t   yes(   R   R  R   R   (   R   R   R   t   chosen(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt"   test_quoted_space_in_selector_name  s    c         C   s6   |  j  t |  j j d  |  j  t |  j j d  d  S(   Ns   a:no-such-pseudoclasss   a:nth-of-type(a)(   R   R6  R   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_unsupported_pseudoclass  s    c         C   s   |  j  j d  } |  j t |  d  |  j | d j d  |  j  j d  } |  j t |  d  |  j | d j d  |  j  j d  } |  j t |  d  |  j t |  j  j d  d  S(	   Ns   div#inner p:nth-of-type(1)i   i    u	   Some texts   div#inner p:nth-of-type(3)u   Anothers   div#inner p:nth-of-type(4)s   div p:nth-of-type(0)(   R   R  R   R&   R   R   R   (   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_nth_of_type  s    c         C   sC   |  j  j d  } |  j t |  d  |  j | d j d  d  S(   Ns   div#inner > p:nth-of-type(1)i   i    u	   Some text(   R   R  R   R&   R   (   R   R  (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt"   test_nth_of_type_direct_descendant  s    c         C   s   |  j  d d g  d  S(   Ns   #inner > p:nth-of-type(2)R  (   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt"   test_id_child_selector_nth_of_type  s    c         C   sA   |  j  j d d d } | j d  } |  j | d d g  d  S(   NRX   R   R  R  R  (   R   R    R  R   (   R   R  t   selected(    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_select_on_element  s    c         C   s'   |  j  d d g  |  j  d g   d  S(   Ns   .fancy #innerR  s   .normal #inner(   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_overspecified_child_id  s    c         C   sY   |  j  d d g  |  j  d d g  |  j  d d g  |  j g  |  j j d   d  S(   Ns   #p1 + h2R  s   #p1 + h2 + pR$  s   #p1 + #header2 + .class1s   #p1 + p(   R   R   R   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_adjacent_sibling_selector  s    c         C   so   |  j  d d d g  |  j  d d g  |  j  d d g  |  j  d d g  |  j g  |  j j d   d  S(	   Ns   #p1 ~ h2R  R  s   #p1 ~ #header2s   #p1 ~ h2 + aR0  s   #p1 ~ h2 + [rel="me"]s   #inner ~ h2(   R   R   R   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_general_sibling_selector  s
    c         C   s   |  j  t |  j j d  d  S(   Ns   h1 >(   R   R   R   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_dangling_combinator  s    c         C   s   |  j  d d d d g  d  S(   Ns   p[lang] ~ ps
   lang-en-gbs
   lang-en-uss   lang-fr(   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt2   test_sibling_combinator_wont_select_same_tag_twice  s    c         C   s   |  j  d d d g  d  S(   Ns   x, yt   xidt   yid(   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_multiple_select  s    c         C   s   |  j  d d d g  d  S(   Ns   x,yRE  RF  (   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt"   test_multiple_select_with_no_space  s    c         C   s   |  j  d d d g  d  S(   Ns   x,    yRE  RF  (   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt$   test_multiple_select_with_more_space  s    c         C   s   |  j  d d g  d  S(   Ns   x, xRE  (   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_multiple_select_duplicated  s    c         C   s   |  j  d d d g  d  S(   Ns   x, y ~ p[lang=fr]RE  s   lang-fr(   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_multiple_select_sibling  s    c         C   s   |  j  d d d g  d  S(   Ns   x, y > zRE  t   zidb(   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt.   test_multiple_select_tag_and_direct_descendant  s    c         C   s&   |  j  d d d d d d d g  d  S(   Ns   div > x, y, zRE  RF  t   zidaRL  t   zidabt   zidac(   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt/   test_multiple_select_direct_descendant_and_tags
  s    c         C   s&   |  j  d d d d d d d g  d  S(   Ns   div x,y,  zRE  RF  RN  RL  RO  RP  (   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt(   test_multiple_select_indirect_descendant  s    c         C   s6   |  j  t |  j j d  |  j  t |  j j d  d  S(   Ns   ,x, ys   x,,y(   R   R   R   R  (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_invalid_multiple_select  s    c         C   s   |  j  d d d g  d  S(   Ns   p[lang=en], p[lang=en-gb]s   lang-ens
   lang-en-gb(   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_multiple_select_attrs  s    c         C   s   |  j  d d d d g  d  S(   Ns*   x, y > z[id=zida], z[id=zidab], z[id=zidb]RE  RL  RO  (   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_multiple_select_ids  s    c         C   s   |  j  d d d g  d  S(   Ns   body > div > x, y > zRE  RL  (   R   (   R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_multiple_select_nested  s    c         C   ss   d } t  | d  } | j d  } |  j d t |   x2 | j d d d g  D] } | | k sS t  qS Wd  S(   Ns3   <div class="c1"/><div class="c2"/><div class="c1"/>s   html.parsers   .c1, .c2i   Rl   t   c1t   c2(   R   R  R  R&   R'   R  (   R   R   R   R>  R   (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   test_select_duplicate_elements  s    (=   R   R   R  RJ   R   R  R  R   R  R  R	  R  R  R  R  R  R  R  R  R  R  R  R   R!  R"  R#  R%  R&  R*  R+  R-  R/  R1  R3  R4  R5  R6  R9  R:  R;  R<  R=  R?  R@  RA  RB  RC  RD  RG  RH  RI  RJ  RK  RM  RQ  RR  RS  RT  RU  RV  RY  (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyR    sv   1		
																													
																											(3   R+   t   pdbR    R  R  R/   Rf  t   bs4R   t   bs4.builderR   R   t   bs4.elementR   R   R   R   R   R	   R
   R   t   bs4.testingR   R   R   R{   R   t   LXML_PRESENTR   R   R,   RC   RH   R^   R   R   R   R   R   R   R   R   R   R   Rb  R  R  R  R  R  R  (    (    (    s7   /usr/lib/python2.7/site-packages/bs4/tests/test_tree.pyt   <module>   sF   :
;O3(3--* n+a4*