mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
merge with 0.6
This commit is contained in:
@@ -4,9 +4,9 @@ import sys, os
|
||||
|
||||
sys.path.append(os.path.abspath('.'))
|
||||
|
||||
extensions = ['ext', 'sphinx.ext.autodoc', 'sphinx.ext.jsmath',
|
||||
'sphinx.ext.coverage', 'sphinx.ext.todo',
|
||||
'sphinx.ext.autosummary', 'sphinx.ext.extlinks']
|
||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.jsmath', 'sphinx.ext.todo',
|
||||
'sphinx.ext.coverage', 'sphinx.ext.autosummary',
|
||||
'sphinx.ext.doctest', 'sphinx.ext.extlinks', 'ext']
|
||||
|
||||
jsmath_path = 'dummy.js'
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ Contents:
|
||||
autosummary
|
||||
metadata
|
||||
extensions
|
||||
doctest
|
||||
|
||||
Python <http://python.org/>
|
||||
|
||||
|
||||
120
tests/root/doctest.txt
Normal file
120
tests/root/doctest.txt
Normal file
@@ -0,0 +1,120 @@
|
||||
Testing the doctest extension
|
||||
=============================
|
||||
|
||||
Simple doctest blocks
|
||||
---------------------
|
||||
|
||||
>>> 1+1
|
||||
2
|
||||
>>> 1/0
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ZeroDivisionError: integer division or modulo by zero
|
||||
|
||||
|
||||
Special directives
|
||||
------------------
|
||||
|
||||
* doctest
|
||||
|
||||
.. doctest::
|
||||
|
||||
>>> 1+1
|
||||
2
|
||||
>>> 1/0
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ZeroDivisionError: integer division or modulo by zero
|
||||
|
||||
* testcode/testoutput
|
||||
|
||||
.. testcode::
|
||||
|
||||
print 1+1
|
||||
|
||||
.. testoutput::
|
||||
|
||||
2
|
||||
|
||||
.. testcode::
|
||||
|
||||
1/0
|
||||
|
||||
.. testoutput::
|
||||
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ZeroDivisionError: integer division or modulo by zero
|
||||
|
||||
* testsetup
|
||||
|
||||
.. testsetup:: *
|
||||
|
||||
from math import floor
|
||||
|
||||
.. doctest::
|
||||
|
||||
>>> floor(1.2)
|
||||
1.0
|
||||
|
||||
.. testcode::
|
||||
|
||||
print floor(1.2)
|
||||
|
||||
.. testoutput::
|
||||
|
||||
1.0
|
||||
|
||||
>>> floor(1.2)
|
||||
1.0
|
||||
|
||||
* options for testcode/testoutput blocks
|
||||
|
||||
.. testcode::
|
||||
:hide:
|
||||
|
||||
print 'Output text.'
|
||||
|
||||
.. testoutput::
|
||||
:hide:
|
||||
:options: +NORMALIZE_WHITESPACE
|
||||
|
||||
Output text.
|
||||
|
||||
* grouping
|
||||
|
||||
.. testsetup:: group1
|
||||
|
||||
from math import ceil
|
||||
|
||||
``ceil`` is now known in "group1", but not in others.
|
||||
|
||||
.. doctest:: group1
|
||||
|
||||
>>> ceil(0.8)
|
||||
1.0
|
||||
|
||||
.. doctest:: group2
|
||||
|
||||
>>> ceil(0.8)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
NameError: name 'ceil' is not defined
|
||||
|
||||
Interleaving testcode/testoutput:
|
||||
|
||||
.. testcode:: group1
|
||||
|
||||
print ceil(0.8)
|
||||
|
||||
.. testcode:: group2
|
||||
|
||||
print floor(0.8)
|
||||
|
||||
.. testoutput:: group1
|
||||
|
||||
1.0
|
||||
|
||||
.. testoutput:: group2
|
||||
|
||||
0.0
|
||||
24
tests/test_doctest.py
Normal file
24
tests/test_doctest.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
test_doctest
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Test the doctest extension.
|
||||
|
||||
:copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import StringIO
|
||||
|
||||
from util import *
|
||||
|
||||
status = StringIO.StringIO()
|
||||
|
||||
@with_app(buildername='doctest', status=status)
|
||||
def test_build(app):
|
||||
app.builder.build_all()
|
||||
if app.statuscode != 0:
|
||||
print >>sys.stderr, status.getvalue()
|
||||
assert False, 'failures in doctests'
|
||||
Reference in New Issue
Block a user