From 50d5d97a179fa6ea8b003fc7117d62d639001c84 Mon Sep 17 00:00:00 2001 From: Graham Smith Date: Sat, 12 Nov 2022 18:02:22 +0000 Subject: [PATCH] Add unit tests --- tests/test_builder.py | 69 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tests/test_builder.py b/tests/test_builder.py index a64d04d..11a90f7 100644 --- a/tests/test_builder.py +++ b/tests/test_builder.py @@ -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"