B
ª `j³ ã @ sÎ d Z dZddlZddlZddlZddlZddlmZ ddlmZ ddl m
Z
mZmZm
Z
mZmZmZmZmZ ddlmZ eZdZG d d
„ d
ejƒZG dd„ deƒZG d
d„ deƒZG dd„ deƒZdd„ ZdS )zHelper classes for tests.ÚMITé N)ÚTestCase)Ú
BeautifulSoup) ÚCharsetMetaAttributeValueÚCommentÚContentMetaAttributeValueÚDoctypeÚPYTHON_SPECIFIC_ENCODINGSÚSoupStrainerÚScriptÚ
StylesheetÚTag)ÚHTMLParserTreeBuilderu-
A bare string
A tag
A tag that supposedly has contents.
AT&T
This numeric entity is missing the final semicolon:
a
This document contains (do you see it?)
The doctype is invalid because it contains extra whitespace
That boolean attribute had no value
Here's a nonexistent entity: foo; (do you see it?)
This document ends before the entity finishes: >
Paragraphs shouldn't contain block display elements, but this one does:
you see?
Multiple values for the same attribute.
Here's a nested table:
This tag contains nothing but whitespace:
This p tag is cut off by
the end of the blockquote tag
This table contains bare markup
This document contains a surprise doctype
Tag name contains Unicode characters
c @ sD e Zd Zedd„ ƒZdd„ Zdd„ Zddd „Zd
d„ Zdd
d„Z dS )ÚSoupTestc C s t S )N)Údefault_builder)Úself© r úk/private/var/folders/fw/jsxvvqfs4sz4tdnfdvg5typ5vk77qg/T/pip-install-p7nfy4dm/beautifulsoup4/bs4/testing.pyr C s zSoupTest.default_builderc K s" | d| j¡}t|fd|i|—ŽS )z*Build a Beautiful Soup object from markup.Úbuilder)Úpopr r )r ÚmarkupÚkwargsr r r r ÚsoupG s z
SoupTest.soupc K s | j f |Ž |¡S )z[Turn an HTML fragment into a document.
The details depend on the builder.
)r Ztest_fragment_to_document)r r r r r r Údocument_forL s zSoupTest.document_forNc C st | j }t||d}|d kr|}| | ¡ | |¡¡ tdd„ t|j ¡ ƒD ƒƒsTt ‚| |j
gdd„ |jD ƒ¡ d S )N)r c s s | ]}|d kV qdS )r Nr )Ú.0Úvr r r ú a s z,SoupTest.assertSoupEquals..c S s g | ]
}|j ‘qS r )Úname)r Úxr r r ú
f s z-SoupTest.assertSoupEquals..)r r ÚassertEqualÚdecoder ÚallÚlistZopen_tag_counterÚvaluesÚAssertionErrorZ
ROOT_TAG_NAMEZtagStack)r Zto_parseZcompare_parsed_tor Úobjr r r ÚassertSoupEqualsS s zSoupTest.assertSoupEqualsc C s<