# Path: tests/testing_utils.py
# def assert_no_logs(function):
#     """Decorator that asserts that nothing is logged in a function."""
#     @functools.wraps(function)
#     def wrapper(*args, **kwargs):
#         with capture_logs() as logs:
#             try:
#                 function(*args, **kwargs)
#             except Exception:  # pragma: no cover
#                 if logs:
#                     print(f'{len(logs)} errors logged:', file=sys.stderr)
#                     for message in logs:
#                         print(message, file=sys.stderr)
#                 raise
#             else:
#                 if logs:  # pragma: no cover
#                     for message in logs:
#                         print(message, file=sys.stderr)
#                     raise AssertionError(f'{len(logs)} errors logged')
#     return wrapper
# 
# def render_pages(html_content):
#     """Lay out a document and return a list of PageBox objects."""
#     return [
#         page._page_box for page in
#         FakeHTML(string=html_content, base_url=BASE_URL).render().pages]
# 
# def tree_position(box_list, matcher):
#     """Return a list identifying the first matching box's tree position.
# 
#     Given a list of Boxes, this function returns a list containing the first
#     (depth-first) Box that the matcher function identifies. This list can then
#     be compared to another similarly-obtained list to assert that one Box is in
#     the document tree before or after another.
# 
#     box_list: a list of Box objects, possibly PageBoxes
#     matcher: a function that takes a Box and returns truthy when it matches
# 
#     """
#     for i, box in enumerate(box_list):
#         if matcher(box):
#             return [i]
#         elif hasattr(box, 'children'):
#             position = tree_position(box.children, matcher)
#             if position:
#                 return [i] + position


import pytest
from ..testing_utils import assert_no_logs, render_pages, tree_position
    ('p + p { break-before: avoid }', '</p><p>e<br>f'),
    ('p + p { break-before: avoid }', '<span>y</span><span>z</span></p><p>e'),
))
def test_footnote_area_after_call(css, tail):
    pages = render_pages('''
        <style>
            @font-face {src: url(weasyprint.otf); font-family: weasyprint}
            @page {
                size: 9px 10px;
                background: white;
                margin: 0;
            }
            body {
                font-family: weasyprint;
                font-size: 2px;
                line-height: 1;
                orphans: 2;
                widows: 2;
                margin: 0;
            }
            span {
                float: footnote;
            }
            %s
        </style>
        <div>a<br>b</div>
        <p>c<br>d<span>x</span>%s</p>''' % (css, tail))

    footnote_call = tree_position(
        pages, lambda box: box.element_tag == 'p::footnote-call')

# Path: tests/testing_utils.py
# def assert_no_logs(function):
#     """Decorator that asserts that nothing is logged in a function."""
#     @functools.wraps(function)
#     def wrapper(*args, **kwargs):
#         with capture_logs() as logs:
#             try:
#                 function(*args, **kwargs)
#             except Exception:  # pragma: no cover
#                 if logs:
#                     print(f'{len(logs)} errors logged:', file=sys.stderr)
#                     for message in logs:
#                         print(message, file=sys.stderr)
#                 raise
#             else:
#                 if logs:  # pragma: no cover
#                     for message in logs:
#                         print(message, file=sys.stderr)
#                     raise AssertionError(f'{len(logs)} errors logged')
#     return wrapper
# 
# def render_pages(html_content):
#     """Lay out a document and return a list of PageBox objects."""
#     return [
#         page._page_box for page in
#         FakeHTML(string=html_content, base_url=BASE_URL).render().pages]
# 
# def tree_position(box_list, matcher):
#     """Return a list identifying the first matching box's tree position.
# 
#     Given a list of Boxes, this function returns a list containing the first
#     (depth-first) Box that the matcher function identifies. This list can then
#     be compared to another similarly-obtained list to assert that one Box is in
#     the document tree before or after another.
# 
#     box_list: a list of Box objects, possibly PageBoxes
#     matcher: a function that takes a Box and returns truthy when it matches
# 
#     """
#     for i, box in enumerate(box_list):
#         if matcher(box):
#             return [i]
#         elif hasattr(box, 'children'):
#             position = tree_position(box.children, matcher)
#             if position:
#                 return [i] + position


# Path: tests/layout/test_footnotes.py
import pytest
from ..testing_utils import assert_no_logs, render_pages, tree_position

    ('p + p { break-before: avoid }', '</p><p>e<br>f'),
    ('p + p { break-before: avoid }', '<span>y</span><span>z</span></p><p>e'),
))
def test_footnote_area_after_call(css, tail):
    pages = render_pages('''
        <style>
            @font-face {src: url(weasyprint.otf); font-family: weasyprint}
            @page {
                size: 9px 10px;
                background: white;
                margin: 0;
            }
            body {
                font-family: weasyprint;
                font-size: 2px;
                line-height: 1;
                orphans: 2;
                widows: 2;
                margin: 0;
            }
            span {
                float: footnote;
            }
            %s
        </style>
        <div>a<br>b</div>
        <p>c<br>d<span>x</span>%s</p>''' % (css, tail))

    footnote_call = tree_position(
        pages, lambda box: box.element_tag == 'p::footnote-call')

    footnote_area = tree_position(