# Path: readme_renderer/rst.py
# def render(raw, stream=None, **kwargs):
#     if stream is None:
#         # Use a io.StringIO as the warning stream to prevent warnings from
#         # being printed to sys.stderr.
#         stream = io.StringIO()
# 
#     settings = SETTINGS.copy()
#     settings["warning_stream"] = stream
# 
#     writer = Writer()
#     writer.translator_class = ReadMeHTMLTranslator
# 
#     try:
#         parts = publish_parts(raw, writer=writer, settings_overrides=settings)
#     except SystemMessage:
#         rendered = None
#     else:
#         rendered = parts.get("docinfo", "") + parts.get("fragment", "")
# 
#     if rendered:
#         return clean(rendered)
#     else:
#         return None


import io
import glob
import os.path
import pytest
from readme_renderer.rst import render



@pytest.mark.parametrize(
    ("rst_filename", "html_filename"),
    [
        (fn, os.path.splitext(fn)[0] + ".html")
        for fn in glob.glob(
            os.path.join(os.path.dirname(__file__), "fixtures", "test_*.rst")
        )
    ],
)
def test_rst_fixtures(rst_filename, html_filename):
    # Get our Markup
    with io.open(rst_filename, encoding='utf-8') as f:
        rst_markup = f.read()

    # Get our expected
    with io.open(html_filename, encoding="utf-8") as f:
        expected = f.read()

    out = render(rst_markup)

    if "<" in expected:
        assert out == expected
    else:
        assert out is None


def test_rst_001():

# Path: readme_renderer/rst.py
# def render(raw, stream=None, **kwargs):
#     if stream is None:
#         # Use a io.StringIO as the warning stream to prevent warnings from
#         # being printed to sys.stderr.
#         stream = io.StringIO()
# 
#     settings = SETTINGS.copy()
#     settings["warning_stream"] = stream
# 
#     writer = Writer()
#     writer.translator_class = ReadMeHTMLTranslator
# 
#     try:
#         parts = publish_parts(raw, writer=writer, settings_overrides=settings)
#     except SystemMessage:
#         rendered = None
#     else:
#         rendered = parts.get("docinfo", "") + parts.get("fragment", "")
# 
#     if rendered:
#         return clean(rendered)
#     else:
#         return None


# Path: tests/test_rst.py
import io
import glob
import os.path
import pytest
from readme_renderer.rst import render




@pytest.mark.parametrize(
    ("rst_filename", "html_filename"),
    [
        (fn, os.path.splitext(fn)[0] + ".html")
        for fn in glob.glob(
            os.path.join(os.path.dirname(__file__), "fixtures", "test_*.rst")
        )
    ],
)
def test_rst_fixtures(rst_filename, html_filename):
    # Get our Markup
    with io.open(rst_filename, encoding='utf-8') as f:
        rst_markup = f.read()

    # Get our expected
    with io.open(html_filename, encoding="utf-8") as f:
        expected = f.read()

    out = render(rst_markup)

    if "<" in expected:
        assert out == expected
    else:
        assert out is None


def test_rst_001():

    assert render('Hello') == '<p>Hello</p>\n'