# 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
    # https://drafts.csswg.org/selectors-3/#selector-syntax
    # This limitation doesn’t exist anymore in Selectors Level 4:
    # https://drafts.csswg.org/selectors-4/#typedef-compound-selector
    page, = render_pages('''
        <style>
            @font-face {src: url(weasyprint.otf); font-family: weasyprint}
            @page {
                size: 9px 7px;
                background: white;
            }
            div {
                font-family: weasyprint;
                font-size: 2px;
                line-height: 1;
            }
            span {
                float: footnote;
            }
            ::footnote-marker::after {
                content: '|';
            }
        </style>
        <div>abc<span>de</span></div>''')
    html, footnote_area = page.children
    footnote_marker, _ = footnote_area.children[0].children[0].children
    assert footnote_marker.children[0].text == '1.|'


@assert_no_logs
def test_several_footnote():

# 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

    # https://drafts.csswg.org/selectors-3/#selector-syntax
    # This limitation doesn’t exist anymore in Selectors Level 4:
    # https://drafts.csswg.org/selectors-4/#typedef-compound-selector
    page, = render_pages('''
        <style>
            @font-face {src: url(weasyprint.otf); font-family: weasyprint}
            @page {
                size: 9px 7px;
                background: white;
            }
            div {
                font-family: weasyprint;
                font-size: 2px;
                line-height: 1;
            }
            span {
                float: footnote;
            }
            ::footnote-marker::after {
                content: '|';
            }
        </style>
        <div>abc<span>de</span></div>''')
    html, footnote_area = page.children
    footnote_marker, _ = footnote_area.children[0].children[0].children
    assert footnote_marker.children[0].text == '1.|'


@assert_no_logs
def test_several_footnote():

    page1, page2, = render_pages('''