summaryrefslogtreecommitdiff
path: root/tests/test_ext_viewcode.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-09-21 17:17:02 +0200
committerGeorg Brandl <georg@python.org>2014-09-21 17:17:02 +0200
commit9d4d2075518f900a4b294c76fbbe55469b9329f5 (patch)
tree08d92669490358b284d2edd9ba4d61b64c52042a /tests/test_ext_viewcode.py
parent675ee673d9e982a4b975d36630ff3af5ddceccd6 (diff)
downloadsphinx-9d4d2075518f900a4b294c76fbbe55469b9329f5.tar.gz
Complete test suite overhaul.
* rename a few test modules to make the names more consistent * do not copy/use Sphinx from build/ (unnecessary without 2to3) * use a temporary dir for *all* test projects, the source tree will stay pristine that way (default is tests/build) * speed up tests by ~3x by splitting up test projects and avoiding rebuilds
Diffstat (limited to 'tests/test_ext_viewcode.py')
-rw-r--r--tests/test_ext_viewcode.py75
1 files changed, 32 insertions, 43 deletions
diff --git a/tests/test_ext_viewcode.py b/tests/test_ext_viewcode.py
index 60ab7941..561fcb6a 100644
--- a/tests/test_ext_viewcode.py
+++ b/tests/test_ext_viewcode.py
@@ -1,43 +1,32 @@
-# -*- coding: utf-8 -*-
-"""
- test_ext_viewcode
- ~~~~~~~~~~~~~~~~~
-
- Test sphinx.ext.viewcode extension.
-
- :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-
-import re
-
-from six import StringIO
-
-from util import test_roots, with_app
-
-
-warnfile = StringIO()
-root = test_roots / 'test-ext-viewcode'
-doctreedir = root / '_build' / 'doctree'
-
-
-def teardown_module():
- (root / '_build').rmtree(True)
-
-
-@with_app(srcdir=root, warning=warnfile)
-def test_simple(app):
- app.builder.build_all()
-
- warnings = re.sub(r'\\+', '/', warnfile.getvalue())
- assert re.findall(
- r"index.rst:\d+: WARNING: Object named 'func1' not found in include " +
- r"file .*/spam/__init__.py'",
- warnings
- )
-
- result = (app.outdir / 'index.html').text(encoding='utf-8')
- assert result.count('href="_modules/spam/mod1.html#func1"') == 2
- assert result.count('href="_modules/spam/mod2.html#func2"') == 2
- assert result.count('href="_modules/spam/mod1.html#Class1"') == 2
- assert result.count('href="_modules/spam/mod2.html#Class2"') == 2
+# -*- coding: utf-8 -*-
+"""
+ test_ext_viewcode
+ ~~~~~~~~~~~~~~~~~
+
+ Test sphinx.ext.viewcode extension.
+
+ :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import re
+
+from util import with_app
+
+
+@with_app(testroot='ext-viewcode')
+def test_simple(app, status, warning):
+ app.builder.build_all()
+
+ warnings = re.sub(r'\\+', '/', warning.getvalue())
+ assert re.findall(
+ r"index.rst:\d+: WARNING: Object named 'func1' not found in include " +
+ r"file .*/spam/__init__.py'",
+ warnings
+ )
+
+ result = (app.outdir / 'index.html').text(encoding='utf-8')
+ assert result.count('href="_modules/spam/mod1.html#func1"') == 2
+ assert result.count('href="_modules/spam/mod2.html#func2"') == 2
+ assert result.count('href="_modules/spam/mod1.html#Class1"') == 2
+ assert result.count('href="_modules/spam/mod2.html#Class2"') == 2