# 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]


import pytest
from ..testing_utils import assert_no_logs, render_pages
    assert div_1.position_x > div_2.position_x > div_3.position_x


@assert_no_logs
def test_flex_direction_row_reverse():
    page, = render_pages('''
      <article style="display: flex; flex-direction: row-reverse">
        <div>A</div>
        <div>B</div>
        <div>C</div>
      </article>
    ''')
    html, = page.children
    body, = html.children
    article, = body.children
    div_1, div_2, div_3 = article.children
    assert div_1.children[0].children[0].text == 'C'
    assert div_2.children[0].children[0].text == 'B'
    assert div_3.children[0].children[0].text == 'A'
    assert (
        div_1.position_y ==
        div_2.position_y ==
        div_3.position_y ==
        article.position_y)
    assert (
        div_3.position_x + div_3.width ==
        article.position_x + article.width)
    assert div_1.position_x < div_2.position_x < div_3.position_x



# 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]


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

    assert div_1.position_x > div_2.position_x > div_3.position_x


@assert_no_logs
def test_flex_direction_row_reverse():
    page, = render_pages('''
      <article style="display: flex; flex-direction: row-reverse">
        <div>A</div>
        <div>B</div>
        <div>C</div>
      </article>
    ''')
    html, = page.children
    body, = html.children
    article, = body.children
    div_1, div_2, div_3 = article.children
    assert div_1.children[0].children[0].text == 'C'
    assert div_2.children[0].children[0].text == 'B'
    assert div_3.children[0].children[0].text == 'A'
    assert (
        div_1.position_y ==
        div_2.position_y ==
        div_3.position_y ==
        article.position_y)
    assert (
        div_3.position_x + div_3.width ==
        article.position_x + article.width)
    assert div_1.position_x < div_2.position_x < div_3.position_x



@assert_no_logs