bs4.tests.test_tag#

Module Contents#

Classes#

TestTag

Test various methods of Tag which aren't so complicated they

TestMultiValuedAttributes

Test the behavior of multi-valued attributes like 'class'.

class bs4.tests.test_tag.TestTag#

Bases: bs4.tests.SoupTest

Test various methods of Tag which aren’t so complicated they need their own classes.

test__should_pretty_print()#
test_len()#

The length of a Tag is its number of children.

test_member_access_invokes_find()#

Accessing a Python member .foo invokes find(‘foo’)

test_deprecated_member_access()#
test_has_attr()#

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.

test_attributes_come_out_in_alphabetical_order()#
test_string()#
test_empty_tag_has_no_string()#
test_tag_with_multiple_children_has_no_string()#
test_tag_with_recursive_string_has_string()#
test_lack_of_string()#

Only a Tag containing a single text node has a .string.

test_all_text()#

Tag.text and Tag.get_text(sep=u””) -> all child text, concatenated

test_get_text_ignores_special_string_containers()#
test_all_strings_ignores_special_string_containers()#
test_string_methods_inside_special_string_container_tags()#
class bs4.tests.test_tag.TestMultiValuedAttributes#

Bases: bs4.tests.SoupTest

Test the behavior of multi-valued attributes like ‘class’.

The values of such attributes are always presented as lists.

test_single_value_becomes_list()#
test_multiple_values_becomes_list()#
test_multiple_values_separated_by_weird_whitespace()#
test_attributes_joined_into_string_on_output()#
test_get_attribute_list()#
test_accept_charset()#
test_cdata_attribute_applying_only_to_one_tag()#
test_customization()#