Package: src:python-mechanicalsoup
Version: 1.3.0-2
Tags: ftbfs sid forky
User: debian-xml-sgml-p...@lists.alioth.debian.org
Usertags: libxml2.14
[this bug is NOT targeted to the upcoming trixie release]
Note that lxml also needs to be built with libxml 2.14.x from experimental.
[...]
75s =================================== FAILURES
===================================
75s _____________________ test_select_form_associated_elements
_____________________
75s
75s def test_select_form_associated_elements():
75s """Test associated elements outside the form tag"""
75s forms = """<form id="a"><input><textarea></form><input
form="a">
75s <textarea form="a"/><input form="b">
75s <form id="ab" action="/test.php"><input></form>
75s <textarea form="ab"></textarea>
75s """
75s with mechanicalsoup.StatefulBrowser() as browser:
75s browser.open_fake_page(forms)
75s elements_form_a = set([
75s "<input/>", "<textarea></textarea>",
75s '<input form="a"/>', '<textarea
form="a"></textarea>'])
75s elements_form_ab = set(["<input/>", '<textarea
form="ab"></textarea>'])
75s form_by_str = browser.select_form("#a")
75s form_by_tag =
browser.select_form(browser.page.find("form", id='a'))
75s > form_by_css = browser.select_form("form[action$='.php']")
75s
75s tests/test_stateful_browser.py:514:
75s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _
75s
75s self = <mechanicalsoup.stateful_browser.StatefulBrowser object at
0x71f654fcfd90>
75s selector = "form[action$='.php']", nr = 0
75s
75s def select_form(self, selector="form", nr=0):
75s """Select a form in the current page.
75s
75s :param selector: CSS selector or a bs4.element.Tag object
to identify
75s the form to select.
75s If not specified, ``selector`` defaults to "form",
which is
75s useful if, e.g., there is only one form on the page.
75s For ``selector`` syntax, see the `.select() method in
BeautifulSoup
75s
<https://www.crummy.com/software/BeautifulSoup/bs4/doc/#css-selectors>`__.
75s :param nr: A zero-based index specifying which form among
those that
75s match ``selector`` will be selected. Useful when one
or more forms
75s have the same attributes as the form you want to
select, and its
75s position on the page is the only way to uniquely
identify it.
75s Default is the first matching form (``nr=0``).
75s
75s :return: The selected form as a soup object. It can also be
75s retrieved later with the :attr:`form` attribute.
75s """
75s
75s def find_associated_elements(form_id):
75s """Find all elements associated to a form
75s (i.e. an element with a form attribute ->
``form=form_id``)
75s """
75s
75s # Elements which can have a form owner
75s elements_with_owner_form = ("input", "button", "fieldset",
75s "object", "output", "select",
75s "textarea")
75s
75s found_elements = []
75s
75s for element in elements_with_owner_form:
75s found_elements.extend(
75s self.page.find_all(element, form=form_id)
75s )
75s return found_elements
75s
75s if isinstance(selector, bs4.element.Tag):
75s if selector.name != "form":
75s raise LinkNotFoundError
75s form = selector
75s else:
75s # nr is a 0-based index for consistency with mechanize
75s found_forms = self.page.select(selector,
75s limit=nr + 1)
75s if len(found_forms) != nr + 1:
75s if self.__debug:
75s print('select_form failed for', selector)
75s self.launch_browser()
75s > raise LinkNotFoundError()
75s E mechanicalsoup.utils.LinkNotFoundError
75s
75s
/usr/lib/python3/dist-packages/mechanicalsoup/stateful_browser.py:241:
LinkNotFoundError
75s =========================== short test summary info
============================
75s FAILED
tests/test_stateful_browser.py::test_select_form_associated_elements
75s ================= 1 failed, 111 passed, 8 deselected in 1.24s
==================