Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit baa95e9

Browse files
author
Ed Slavich
committed
Add test of :skip: with stdlib objects
1 parent bcc41ff commit baa95e9

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""
2+
A module that imports objects from the standard library.
3+
"""
4+
from pathlib import Path
5+
from datetime import time
6+
7+
8+
def add(a, b):
9+
"""
10+
Add two numbers
11+
"""
12+
return a + b

sphinx_automodapi/tests/test_automodapi.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,56 @@ def test_am_replacer_skip(tmpdir):
327327
assert result == am_replacer_skip_expected
328328

329329

330+
am_replacer_skip_stdlib_str = """
331+
This comes before
332+
333+
.. automodapi:: sphinx_automodapi.tests.example_module.stdlib
334+
:skip: time
335+
:skip: Path
336+
337+
This comes after
338+
"""
339+
340+
341+
am_replacer_skip_stdlib_expected = """
342+
This comes before
343+
344+
345+
sphinx_automodapi.tests.example_module.stdlib Module
346+
----------------------------------------------------
347+
348+
.. automodule:: sphinx_automodapi.tests.example_module.stdlib
349+
350+
Functions
351+
^^^^^^^^^
352+
353+
.. automodsumm:: sphinx_automodapi.tests.example_module.stdlib
354+
:functions-only:
355+
:toctree: api
356+
:skip: time,Path
357+
358+
359+
This comes after
360+
""".format(empty='')
361+
362+
363+
def test_am_replacer_skip_stdlib(tmpdir):
364+
"""
365+
Tests using the ":skip:" option in an ".. automodapi::"
366+
that skips objects imported from the standard library.
367+
"""
368+
369+
with open(tmpdir.join('index.rst').strpath, 'w') as f:
370+
f.write(am_replacer_skip_stdlib_str.format(options=''))
371+
372+
run_sphinx_in_tmpdir(tmpdir)
373+
374+
with open(tmpdir.join('index.rst.automodapi').strpath) as f:
375+
result = f.read()
376+
377+
assert result == am_replacer_skip_stdlib_expected
378+
379+
330380
am_replacer_include_str = """
331381
This comes before
332382

0 commit comments

Comments
 (0)