Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grhm committed Nov 12, 2022
1 parent 1990295 commit 50d5d97
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,72 @@ def test_domain_role_output(sphinx_project):
output_text = None

assert output_text == "The Module\n**********\n\nteh is OK\n"

def test_domain_ignore(sphinx_project):
srcdir, outdir = sphinx_project

add_file(srcdir, 'contents.rst', '''
The Module
==========
:spelling:ignore:`baddddd` is OK
''')

stdout, stderr, output_text = get_sphinx_output(
srcdir,
outdir,
'contents',
)
assert output_text is None


def test_domain_ignore_multiple_words(sphinx_project):
srcdir, outdir = sphinx_project

add_file(srcdir, 'contents.rst', '''
The Module
==========
:spelling:ignore:`baddddd` is OK here.
But, baddddd is not OK here.
Nor, here baddddd.
''')

stdout, stderr, output_text = get_sphinx_output(
srcdir,
outdir,
'contents',
)
assert '(baddddd)' in output_text
assert output_text.count('\n') == 2 # Only expect 2 errors, not 3.


def test_domain_ignore_output(sphinx_project):
srcdir, outdir = sphinx_project

add_file(srcdir, 'contents.rst', '''
The Module
==========
:spelling:ignore:`teh` is OK
''')

stdout, stderr, output_text = get_sphinx_output(
srcdir,
outdir,
'contents',
'text',
)

path = os.path.join(outdir, 'contents.txt')
try:
with open(path, 'r') as f:
output_text = f.read()
except FileNotFoundError:
output_text = None

assert output_text == "The Module\n**********\n\nteh is OK\n"

0 comments on commit 50d5d97

Please sign in to comment.