GitHub

@@ -59,7 +59,7 @@ def _render_options(options: dict[str, Any]) -> str:

5959

return f"<!--\n{json.dumps(options, indent=2, sort_keys=True)}\n-->\n\n"

6060616162-

# Signature options

62+

# Signature tests.

6363

@pytest.fixture(name="signature_package", scope="session")

6464

def _signature_package() -> Iterator[TmpPackage]:

6565

code = """

@@ -108,7 +108,7 @@ def test_end_to_end_for_signatures(

108108

assert outsource(html, suffix=".html") == snapshots_signatures[snapshot_key]

109109110110111-

# Members options.

111+

# Member tests.

112112

@pytest.fixture(name="members_package", scope="session")

113113

def _members_package() -> Iterator[TmpPackage]:

114114

code = """

@@ -171,3 +171,50 @@ def test_end_to_end_for_members(

171171

html = _render_options(final_options) + _render(session_handler, members_package, final_options)

172172

snapshot_key = tuple(sorted(final_options.items()))

173173

assert outsource(html, suffix=".html") == snapshots_members[snapshot_key]

174+175+176+

# Heading tests.

177+

@pytest.fixture(name="headings_package", scope="session")

178+

def _headings_package() -> Iterator[TmpPackage]:

179+

code = """

180+

def module_function(a: int, b: str) -> None:

181+

pass

182+183+

class Class:

184+

class_attribute: int = 42

185+186+

def __init__(self, a: int, b: str) -> None:

187+

self.instance_attribute = a + b

188+189+

def method1(self, a: int, b: str) -> None:

190+

pass

191+192+

module_attribute: int = 42

193+

"""

194+

with temporary_pypackage("headings_package", {"__init__.py": code}) as tmppkg:

195+

yield tmppkg

196+197+198+

@pytest.mark.parametrize("separate_signature", [True, False])

199+

@pytest.mark.parametrize("heading", ["", "Some heading"])

200+

def test_end_to_end_for_headings(

201+

session_handler: PythonHandler,

202+

headings_package: TmpPackage,

203+

separate_signature: bool,

204+

heading: str,

205+

) -> None:

206+

"""Test rendering of a given theme's templates.

207+208+

Parameters:

209+

identifier: Parametrized identifier.

210+

session_handler: Python handler (fixture).

211+

"""

212+

final_options = {

213+

"separate_signature": separate_signature,

214+

"heading": heading,

215+

"show_if_no_docstring": True,

216+

"members": False,

217+

}

218+

html = _render_options(final_options) + _render(session_handler, headings_package, final_options)

219+

snapshot_key = tuple(sorted(final_options.items()))

220+

assert outsource(html, suffix=".html") == snapshots_members[snapshot_key]

Read the original on github.com ↗