mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
make doctest work with python2 and python3
This commit is contained in:
parent
2ce553a71a
commit
1f5c4e6c9c
@ -22,7 +22,7 @@ copyright = '2010, Georg Brandl & Team'
|
||||
version = '0.6'
|
||||
release = '0.6alpha1'
|
||||
today_fmt = '%B %d, %Y'
|
||||
#unused_docs = []
|
||||
# unused_docs = []
|
||||
exclude_patterns = ['_build', '**/excluded.*']
|
||||
keep_warnings = True
|
||||
pygments_style = 'sphinx'
|
||||
|
@ -30,7 +30,7 @@ Special directives
|
||||
|
||||
.. testcode::
|
||||
|
||||
print 1+1
|
||||
print(1+1)
|
||||
|
||||
.. testoutput::
|
||||
|
||||
@ -50,30 +50,30 @@ Special directives
|
||||
|
||||
.. testsetup:: *
|
||||
|
||||
from math import floor
|
||||
from math import factorial
|
||||
|
||||
.. doctest::
|
||||
|
||||
>>> floor(1.2)
|
||||
1.0
|
||||
>>> factorial(1)
|
||||
1
|
||||
|
||||
.. testcode::
|
||||
|
||||
print floor(1.2)
|
||||
print(factorial(1))
|
||||
|
||||
.. testoutput::
|
||||
|
||||
1.0
|
||||
1
|
||||
|
||||
>>> floor(1.2)
|
||||
1.0
|
||||
>>> factorial(1)
|
||||
1
|
||||
|
||||
* options for testcode/testoutput blocks
|
||||
|
||||
.. testcode::
|
||||
:hide:
|
||||
|
||||
print 'Output text.'
|
||||
print('Output text.')
|
||||
|
||||
.. testoutput::
|
||||
:hide:
|
||||
@ -85,36 +85,36 @@ Special directives
|
||||
|
||||
.. testsetup:: group1
|
||||
|
||||
from math import ceil
|
||||
from math import trunc
|
||||
|
||||
``ceil`` is now known in "group1", but not in others.
|
||||
``trunc`` is now known in "group1", but not in others.
|
||||
|
||||
.. doctest:: group1
|
||||
|
||||
>>> ceil(0.8)
|
||||
1.0
|
||||
>>> trunc(1.1)
|
||||
1
|
||||
|
||||
.. doctest:: group2
|
||||
|
||||
>>> ceil(0.8)
|
||||
>>> trunc(1.1)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
NameError: name 'ceil' is not defined
|
||||
NameError: name 'trunc' is not defined
|
||||
|
||||
Interleaving testcode/testoutput:
|
||||
|
||||
.. testcode:: group1
|
||||
|
||||
print ceil(0.8)
|
||||
print(factorial(3))
|
||||
|
||||
.. testcode:: group2
|
||||
|
||||
print floor(0.8)
|
||||
print(factorial(4))
|
||||
|
||||
.. testoutput:: group1
|
||||
|
||||
1.0
|
||||
6
|
||||
|
||||
.. testoutput:: group2
|
||||
|
||||
0.0
|
||||
24
|
||||
|
Loading…
Reference in New Issue
Block a user