File: test_render.py

package info (click to toggle)
sphinxcontrib-openapi 0.8.4-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 876 kB
  • sloc: python: 7,575; makefile: 15
file content (30 lines) | stat: -rw-r--r-- 1,058 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pathlib
import os

import pytest


@pytest.fixture(scope="function")
def rendered():
    return pathlib.Path(os.path.dirname(__file__), "rendered")


@pytest.mark.regenerate_rendered_specs
def test_generate(testrenderer, testspec, rendered):
    testspec_name, testspec = testspec
    rendered_markup = "\n".join(testrenderer.render_restructuredtext_markup(testspec))

    rendered.joinpath(os.path.dirname(testspec_name)).mkdir(parents=True, exist_ok=True)
    rendered.joinpath(testspec_name + ".rst").write_text(rendered_markup)


def test_render(testrenderer, testspec, rendered):
    testspec_name, testspec = testspec
    rendered_markup = "\n".join(testrenderer.render_restructuredtext_markup(testspec))

    # if this is our first time encountering the test, write the response
    if not os.path.exists(rendered.joinpath(testspec_name + ".rst")):
        with rendered.joinpath(testspec_name + ".rst").open("w") as fh:
            fh.write(rendered_markup)

    assert rendered_markup == rendered.joinpath(testspec_name + ".rst").read_text()