2010-01-02 07:59:27 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
test_doctest
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test the doctest extension.
|
|
|
|
|
2017-03-22 06:21:12 -05:00
|
|
|
:copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
|
2010-01-02 07:59:27 -06:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
2017-01-05 10:14:47 -06:00
|
|
|
import pytest
|
2017-01-15 14:07:44 -06:00
|
|
|
from sphinx.ext.doctest import compare_version
|
2013-04-01 04:39:32 -05:00
|
|
|
|
2011-01-03 14:20:29 -06:00
|
|
|
cleanup_called = 0
|
2010-01-02 07:59:27 -06:00
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
|
2017-11-01 10:03:29 -05:00
|
|
|
@pytest.mark.sphinx('doctest', testroot='ext-doctest')
|
2014-09-21 10:17:02 -05:00
|
|
|
def test_build(app, status, warning):
|
2011-01-03 14:20:29 -06:00
|
|
|
global cleanup_called
|
|
|
|
cleanup_called = 0
|
2010-01-02 07:59:27 -06:00
|
|
|
app.builder.build_all()
|
|
|
|
if app.statuscode != 0:
|
2014-09-21 10:17:02 -05:00
|
|
|
assert False, 'failures in doctests:' + status.getvalue()
|
2011-01-03 14:20:29 -06:00
|
|
|
# in doctest.txt, there are two named groups and the default group,
|
|
|
|
# so the cleanup function must be called three times
|
|
|
|
assert cleanup_called == 3, 'testcleanup did not get executed enough times'
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
|
2017-01-15 14:07:44 -06:00
|
|
|
def test_compare_version():
|
|
|
|
assert compare_version('3.3', '3.4', '<') is True
|
|
|
|
assert compare_version('3.3', '3.2', '<') is False
|
|
|
|
assert compare_version('3.3', '3.4', '<=') is True
|
|
|
|
assert compare_version('3.3', '3.2', '<=') is False
|
|
|
|
assert compare_version('3.3', '3.3', '==') is True
|
|
|
|
assert compare_version('3.3', '3.4', '==') is False
|
|
|
|
assert compare_version('3.3', '3.2', '>=') is True
|
|
|
|
assert compare_version('3.3', '3.4', '>=') is False
|
|
|
|
assert compare_version('3.3', '3.2', '>') is True
|
|
|
|
assert compare_version('3.3', '3.4', '>') is False
|
|
|
|
with pytest.raises(ValueError):
|
|
|
|
compare_version('3.3', '3.4', '+')
|
2017-01-14 11:57:19 -06:00
|
|
|
|
|
|
|
|
2011-01-03 14:20:29 -06:00
|
|
|
def cleanup_call():
|
|
|
|
global cleanup_called
|
|
|
|
cleanup_called += 1
|