-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for the spelling builder; use info() instead of printing to…
… stdout directly; ignore the wordlist file created by pyenchant when the tests run
- Loading branch information
Showing
3 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ TAGS | |
\.ropeproject/ | ||
,*~ | ||
.DS_Store | ||
spelling/spelling_wordlist.txt | ||
|
||
syntax: glob | ||
*/distribute-*.tar.gz | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
# | ||
# Copyright (c) 2010 Doug Hellmann. All rights reserved. | ||
# | ||
"""Tests for SpellingBuilder | ||
""" | ||
|
||
import os | ||
import shutil | ||
import tempfile | ||
from cStringIO import StringIO | ||
|
||
from sphinxcontrib import spelling | ||
|
||
from sphinx.application import Sphinx | ||
from sphinx.config import Config | ||
|
||
def setup(): | ||
global _tempdir, _srcdir, _outdir | ||
_tempdir = tempfile.mkdtemp() | ||
_srcdir = os.path.join(_tempdir, 'src') | ||
_outdir = os.path.join(_tempdir, 'out') | ||
os.mkdir(_srcdir) | ||
os.mkdir(_outdir) | ||
|
||
def teardown(): | ||
shutil.rmtree(_tempdir) | ||
|
||
def test_setup(): | ||
with open(os.path.join(_srcdir, 'conf.py'), 'w') as f: | ||
f.write(''' | ||
extensions = [ 'sphinxcontrib.spelling' ] | ||
''') | ||
stdout = StringIO() | ||
stderr = StringIO() | ||
# If the spelling builder is not properly initialized, | ||
# trying to use it with the Sphinx app class will | ||
# generate an exception. | ||
app = Sphinx(_srcdir, _srcdir, _outdir, _outdir, 'spelling', | ||
status=stdout, warning=stderr, | ||
freshenv=True, | ||
) | ||
return | ||
|
||
def test_title(): | ||
with open(os.path.join(_srcdir, 'conf.py'), 'w') as f: | ||
f.write(''' | ||
extensions = [ 'sphinxcontrib.spelling' ] | ||
''') | ||
with open(os.path.join(_srcdir, 'contents.rst'), 'w') as f: | ||
f.write(''' | ||
Welcome to Speeling Checker documentation! | ||
========================================== | ||
''') | ||
stdout = StringIO() | ||
stderr = StringIO() | ||
app = Sphinx(_srcdir, _srcdir, _outdir, _outdir, 'spelling', | ||
status=stdout, warning=stderr, | ||
freshenv=True, | ||
) | ||
app.build() | ||
assert '"Speeling"' in app.builder.output[0] | ||
return | ||
|
||
|
||
def test_body(): | ||
with open(os.path.join(_srcdir, 'conf.py'), 'w') as f: | ||
f.write(''' | ||
extensions = [ 'sphinxcontrib.spelling' ] | ||
''') | ||
with open(os.path.join(_srcdir, 'contents.rst'), 'w') as f: | ||
f.write(''' | ||
Welcome to Spelling Checker documentation! | ||
========================================== | ||
There are several mispelled words in this txt. | ||
''') | ||
stdout = StringIO() | ||
stderr = StringIO() | ||
app = Sphinx(_srcdir, _srcdir, _outdir, _outdir, 'spelling', | ||
status=stdout, warning=stderr, | ||
freshenv=True, | ||
) | ||
app.build() | ||
output_text = app.builder.output[0] | ||
assert '"mispelled"' in output_text | ||
assert '"txt"' in output_text | ||
return | ||
|