<commit_before>from io import StringIO

try:
    from pathlib import Path
except ImportError:
    from pathlib2 import Path
from readme_renderer.rst import render


def test_pypi_rendering():
    # Adapted from `https://stackoverflow.com/questions/46766570/`.
    readme = Path("README.rst")
    warnings = StringIO()
    with readme.open() as file_:
        html = render(file_.read(), stream=warnings)
        warnings.seek(0)
        assert html is not None, warnings.read()
<commit_msg>tests: Skip readme renderer on py 3.9<commit_after>import sys
from io import StringIO

try:
    from pathlib import Path
except ImportError:
    from pathlib2 import Path

import pytest

if sys.version_info < (3, 9):
    from readme_renderer.rst import render
else:
    render = None


@pytest.mark.skipif(render is None, reason="html5lib issue #419")
def test_pypi_rendering():
    # Adapted from `https://stackoverflow.com/questions/46766570/`.
    readme = Path("README.rst")
    warnings = StringIO()
    with readme.open() as file_:
        html = render(file_.read(), stream=warnings)
        warnings.seek(0)
        assert html is not None, warnings.read()

{'fraction_non_alphanumeric': 0.10043290043290043, 'fraction_numerical': 0.024242424242424242, 'mean_word_length': 3.4461538461538463, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5284941', 'n_tokens_mistral': 384, 'n_tokens_neox': 365, 'n_words': 107}