2008-06-05 03:58:43 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Sphinx test suite utilities
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2014-03-01 01:18:16 -06:00
|
|
|
:copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
2008-12-27 05:19:17 -06:00
|
|
|
:license: BSD, see LICENSE for details.
|
2008-06-05 03:58:43 -05:00
|
|
|
"""
|
|
|
|
|
2014-08-03 02:22:08 -05:00
|
|
|
import os
|
2008-06-05 03:58:43 -05:00
|
|
|
import sys
|
|
|
|
import tempfile
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
import shutil
|
2010-06-20 15:39:38 -05:00
|
|
|
import re
|
2013-12-14 23:16:53 -06:00
|
|
|
from functools import wraps
|
2008-06-05 03:58:43 -05:00
|
|
|
|
2014-04-30 07:30:46 -05:00
|
|
|
from six import StringIO
|
2014-04-28 21:46:47 -05:00
|
|
|
|
2008-12-23 13:04:45 -06:00
|
|
|
from sphinx import application
|
2012-11-03 19:30:19 -05:00
|
|
|
from sphinx.theming import Theme
|
2009-02-17 16:55:05 -06:00
|
|
|
from sphinx.ext.autodoc import AutoDirective
|
2008-06-05 03:58:43 -05:00
|
|
|
|
|
|
|
from path import path
|
|
|
|
|
2010-08-21 15:47:18 -05:00
|
|
|
from nose import tools, SkipTest
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
|
2014-08-10 02:28:31 -05:00
|
|
|
try:
|
|
|
|
# Python >=3.3
|
|
|
|
from unittest import mock
|
|
|
|
except ImportError:
|
|
|
|
import mock
|
|
|
|
|
2008-06-05 03:58:43 -05:00
|
|
|
|
|
|
|
__all__ = [
|
2013-01-05 20:14:48 -06:00
|
|
|
'test_root', 'test_roots', 'raises', 'raises_msg',
|
2010-08-21 16:03:06 -05:00
|
|
|
'skip_if', 'skip_unless', 'skip_unless_importable', 'Struct',
|
2009-02-19 15:12:47 -06:00
|
|
|
'ListOutput', 'TestApp', 'with_app', 'gen_with_app',
|
2014-04-28 05:58:26 -05:00
|
|
|
'path', 'with_tempdir',
|
2010-06-20 15:39:38 -05:00
|
|
|
'sprint', 'remove_unicode_literals',
|
2014-08-10 02:28:31 -05:00
|
|
|
'mock',
|
2008-06-05 03:58:43 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
test_root = path(__file__).parent.joinpath('root').abspath()
|
2013-01-05 20:14:48 -06:00
|
|
|
test_roots = path(__file__).parent.joinpath('roots').abspath()
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
|
|
|
|
|
2008-06-05 03:58:43 -05:00
|
|
|
def _excstr(exc):
|
|
|
|
if type(exc) is tuple:
|
|
|
|
return str(tuple(map(_excstr, exc)))
|
|
|
|
return exc.__name__
|
|
|
|
|
|
|
|
def raises(exc, func, *args, **kwds):
|
|
|
|
"""
|
|
|
|
Raise :exc:`AssertionError` if ``func(*args, **kwds)`` does not
|
|
|
|
raise *exc*.
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
func(*args, **kwds)
|
|
|
|
except exc:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
raise AssertionError('%s did not raise %s' %
|
|
|
|
(func.__name__, _excstr(exc)))
|
|
|
|
|
|
|
|
def raises_msg(exc, msg, func, *args, **kwds):
|
|
|
|
"""
|
|
|
|
Raise :exc:`AssertionError` if ``func(*args, **kwds)`` does not
|
|
|
|
raise *exc*, and check if the message contains *msg*.
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
func(*args, **kwds)
|
2014-01-19 04:17:10 -06:00
|
|
|
except exc as err:
|
2008-08-23 10:04:45 -05:00
|
|
|
assert msg in str(err), "\"%s\" not in \"%s\"" % (msg, err)
|
2008-06-05 03:58:43 -05:00
|
|
|
else:
|
|
|
|
raise AssertionError('%s did not raise %s' %
|
|
|
|
(func.__name__, _excstr(exc)))
|
|
|
|
|
2010-08-21 15:47:18 -05:00
|
|
|
def skip_if(condition, msg=None):
|
|
|
|
"""Decorator to skip test if condition is true."""
|
|
|
|
def deco(test):
|
|
|
|
@tools.make_decorator(test)
|
|
|
|
def skipper(*args, **kwds):
|
|
|
|
if condition:
|
|
|
|
raise SkipTest(msg or 'conditional skip')
|
|
|
|
return test(*args, **kwds)
|
|
|
|
return skipper
|
|
|
|
return deco
|
|
|
|
|
|
|
|
def skip_unless(condition, msg=None):
|
|
|
|
"""Decorator to skip test if condition is false."""
|
|
|
|
return skip_if(not condition, msg)
|
|
|
|
|
2010-08-21 16:03:06 -05:00
|
|
|
def skip_unless_importable(module, msg=None):
|
|
|
|
"""Decorator to skip test if module is not importable."""
|
|
|
|
try:
|
|
|
|
__import__(module)
|
|
|
|
except ImportError:
|
|
|
|
return skip_if(True, msg)
|
|
|
|
else:
|
|
|
|
return skip_if(False, msg)
|
|
|
|
|
2008-06-05 03:58:43 -05:00
|
|
|
|
2008-08-04 14:39:05 -05:00
|
|
|
class Struct(object):
|
|
|
|
def __init__(self, **kwds):
|
|
|
|
self.__dict__.update(kwds)
|
|
|
|
|
|
|
|
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
class ListOutput(object):
|
2008-06-05 03:58:43 -05:00
|
|
|
"""
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
File-like object that collects written text in a list.
|
2008-06-05 03:58:43 -05:00
|
|
|
"""
|
|
|
|
def __init__(self, name):
|
|
|
|
self.name = name
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
self.content = []
|
|
|
|
|
|
|
|
def reset(self):
|
|
|
|
del self.content[:]
|
2008-06-05 03:58:43 -05:00
|
|
|
|
|
|
|
def write(self, text):
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
self.content.append(text)
|
2008-06-05 03:58:43 -05:00
|
|
|
|
|
|
|
|
|
|
|
class TestApp(application.Sphinx):
|
|
|
|
"""
|
|
|
|
A subclass of :class:`Sphinx` that runs on the test root, with some
|
|
|
|
better default values for the initialization parameters.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, srcdir=None, confdir=None, outdir=None, doctreedir=None,
|
2009-01-10 15:18:18 -06:00
|
|
|
buildername='html', confoverrides=None,
|
2009-02-19 14:56:34 -06:00
|
|
|
status=None, warning=None, freshenv=None,
|
|
|
|
warningiserror=None, tags=None,
|
2014-08-10 08:23:52 -05:00
|
|
|
confname='conf.py', cleanenv=False,
|
|
|
|
_copy_to_temp=False,
|
|
|
|
):
|
2008-06-05 03:58:43 -05:00
|
|
|
|
|
|
|
application.CONFIG_FILENAME = confname
|
|
|
|
|
2009-03-16 17:46:58 -05:00
|
|
|
self.cleanup_trees = [test_root / 'generated']
|
2008-08-04 17:20:44 -05:00
|
|
|
|
2008-06-05 03:58:43 -05:00
|
|
|
if srcdir is None:
|
Merged revisions 65138,65145-65146,65268-65273 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65138 | georg.brandl | 2008-07-19 15:42:35 +0200 (Sat, 19 Jul 2008) | 2 lines
#3416: fix missing parameter.
........
r65145 | georg.brandl | 2008-07-19 20:01:25 +0200 (Sat, 19 Jul 2008) | 2 lines
Now that we don't ship Jinja anymore by default the comment can go.
........
r65146 | georg.brandl | 2008-07-19 20:01:51 +0200 (Sat, 19 Jul 2008) | 2 lines
Reread documents with globbed toctrees when files are removed/added.
........
r65268 | georg.brandl | 2008-07-29 10:21:33 +0200 (Tue, 29 Jul 2008) | 2 lines
Fix by Markus Gritsch to place correct links to headings.
........
r65269 | georg.brandl | 2008-07-29 10:21:59 +0200 (Tue, 29 Jul 2008) | 2 lines
Make the writer's settings public.
........
r65270 | georg.brandl | 2008-07-29 10:22:28 +0200 (Tue, 29 Jul 2008) | 2 lines
Export test_root.
........
r65271 | georg.brandl | 2008-07-29 10:22:47 +0200 (Tue, 29 Jul 2008) | 2 lines
Add a markup test.
........
r65272 | georg.brandl | 2008-07-29 10:27:19 +0200 (Tue, 29 Jul 2008) | 2 lines
Bump version number.
........
r65273 | georg.brandl | 2008-07-29 11:05:37 +0200 (Tue, 29 Jul 2008) | 2 lines
Correct rendering of ``samp``.
........
2008-07-29 04:07:37 -05:00
|
|
|
srcdir = test_root
|
2013-02-05 08:57:26 -06:00
|
|
|
elif srcdir == '(empty)':
|
|
|
|
tempdir = path(tempfile.mkdtemp())
|
|
|
|
self.cleanup_trees.append(tempdir)
|
|
|
|
temproot = tempdir / 'root'
|
|
|
|
temproot.makedirs()
|
|
|
|
(temproot / 'conf.py').write_text('')
|
|
|
|
srcdir = temproot
|
2008-06-05 03:58:43 -05:00
|
|
|
else:
|
|
|
|
srcdir = path(srcdir)
|
2014-08-10 08:23:52 -05:00
|
|
|
|
|
|
|
if _copy_to_temp:
|
|
|
|
tempdir = path(tempfile.mkdtemp())
|
|
|
|
self.cleanup_trees.append(tempdir)
|
|
|
|
temproot = tempdir / srcdir.basename()
|
|
|
|
srcdir.copytree(temproot)
|
|
|
|
srcdir = temproot
|
|
|
|
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
self.builddir = srcdir.joinpath('_build')
|
2008-06-05 03:58:43 -05:00
|
|
|
if confdir is None:
|
|
|
|
confdir = srcdir
|
|
|
|
if outdir is None:
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
outdir = srcdir.joinpath(self.builddir, buildername)
|
|
|
|
if not outdir.isdir():
|
|
|
|
outdir.makedirs()
|
2008-08-04 17:20:44 -05:00
|
|
|
self.cleanup_trees.insert(0, outdir)
|
2008-06-05 03:58:43 -05:00
|
|
|
if doctreedir is None:
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
doctreedir = srcdir.joinpath(srcdir, self.builddir, 'doctrees')
|
2013-01-05 20:14:48 -06:00
|
|
|
if not doctreedir.isdir():
|
|
|
|
doctreedir.makedirs()
|
2008-08-04 17:20:44 -05:00
|
|
|
if cleanenv:
|
|
|
|
self.cleanup_trees.insert(0, doctreedir)
|
2008-06-05 03:58:43 -05:00
|
|
|
if confoverrides is None:
|
|
|
|
confoverrides = {}
|
|
|
|
if status is None:
|
2014-04-30 07:30:46 -05:00
|
|
|
status = StringIO()
|
2008-06-05 03:58:43 -05:00
|
|
|
if warning is None:
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
warning = ListOutput('stderr')
|
2008-06-05 03:58:43 -05:00
|
|
|
if freshenv is None:
|
2008-08-04 17:20:44 -05:00
|
|
|
freshenv = False
|
2009-02-19 14:56:34 -06:00
|
|
|
if warningiserror is None:
|
|
|
|
warningiserror = False
|
2008-06-05 03:58:43 -05:00
|
|
|
|
|
|
|
application.Sphinx.__init__(self, srcdir, confdir, outdir, doctreedir,
|
|
|
|
buildername, confoverrides, status, warning,
|
2009-02-19 14:56:34 -06:00
|
|
|
freshenv, warningiserror, tags)
|
2008-06-05 03:58:43 -05:00
|
|
|
|
2008-08-04 17:20:44 -05:00
|
|
|
def cleanup(self, doctrees=False):
|
2012-11-03 19:30:19 -05:00
|
|
|
Theme.themes.clear()
|
2009-02-17 16:55:05 -06:00
|
|
|
AutoDirective._registry.clear()
|
2008-08-04 17:20:44 -05:00
|
|
|
for tree in self.cleanup_trees:
|
2008-08-04 16:48:12 -05:00
|
|
|
shutil.rmtree(tree, True)
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
|
2014-07-12 08:14:14 -05:00
|
|
|
def __repr__(self):
|
|
|
|
return '<%s buildername=%r>' % (self.__class__.__name__, self.builder.name)
|
|
|
|
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
|
2008-08-23 10:04:45 -05:00
|
|
|
def with_app(*args, **kwargs):
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
"""
|
|
|
|
Make a TestApp with args and kwargs, pass it to the test and clean up
|
|
|
|
properly.
|
|
|
|
"""
|
|
|
|
def generator(func):
|
|
|
|
@wraps(func)
|
|
|
|
def deco(*args2, **kwargs2):
|
|
|
|
app = TestApp(*args, **kwargs)
|
2009-02-19 15:36:00 -06:00
|
|
|
func(app, *args2, **kwargs2)
|
|
|
|
# don't execute cleanup if test failed
|
|
|
|
app.cleanup()
|
2009-02-19 15:12:47 -06:00
|
|
|
return deco
|
|
|
|
return generator
|
|
|
|
|
|
|
|
|
|
|
|
def gen_with_app(*args, **kwargs):
|
|
|
|
"""
|
2011-05-15 04:15:20 -05:00
|
|
|
Decorate a test generator to pass a TestApp as the first argument to the
|
|
|
|
test generator when it's executed.
|
2009-02-19 15:12:47 -06:00
|
|
|
"""
|
|
|
|
def generator(func):
|
|
|
|
@wraps(func)
|
|
|
|
def deco(*args2, **kwargs2):
|
|
|
|
app = TestApp(*args, **kwargs)
|
2009-02-19 15:36:00 -06:00
|
|
|
for item in func(app, *args2, **kwargs2):
|
|
|
|
yield item
|
|
|
|
# don't execute cleanup if test failed
|
|
|
|
app.cleanup()
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
return deco
|
|
|
|
return generator
|
|
|
|
|
2008-06-05 03:58:43 -05:00
|
|
|
|
|
|
|
def with_tempdir(func):
|
2009-09-09 09:39:38 -05:00
|
|
|
def new_func(*args, **kwds):
|
2008-06-05 03:58:43 -05:00
|
|
|
tempdir = path(tempfile.mkdtemp())
|
2009-09-09 09:39:38 -05:00
|
|
|
func(tempdir, *args, **kwds)
|
2008-06-05 03:58:43 -05:00
|
|
|
tempdir.rmtree()
|
|
|
|
new_func.__name__ = func.__name__
|
|
|
|
return new_func
|
|
|
|
|
|
|
|
|
Merged revisions 65283,65303,65316-65317,65372-65375,65377,65380,65483-65485,65494 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x
........
r65283 | georg.brandl | 2008-07-29 10:07:26 +0000 (Tue, 29 Jul 2008) | 2 lines
Update ez_setup.py.
........
r65303 | benjamin.peterson | 2008-07-30 12:35:34 +0000 (Wed, 30 Jul 2008) | 1 line
add a with_testapp decorator for test functions that passes the TestApp instance in a cleans up after it
........
r65316 | benjamin.peterson | 2008-07-30 23:12:07 +0000 (Wed, 30 Jul 2008) | 1 line
make the app for test_markup global to the module
........
r65317 | benjamin.peterson | 2008-07-30 23:31:29 +0000 (Wed, 30 Jul 2008) | 1 line
make TestApp.cleanup more aggressive
........
r65372 | georg.brandl | 2008-08-01 19:11:22 +0000 (Fri, 01 Aug 2008) | 2 lines
Add more tests, fix a few bugs in image handling.
........
r65373 | georg.brandl | 2008-08-01 19:28:33 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix oversight.
........
r65374 | benjamin.peterson | 2008-08-01 19:36:32 +0000 (Fri, 01 Aug 2008) | 1 line
fix one broken test
........
r65375 | georg.brandl | 2008-08-01 19:41:11 +0000 (Fri, 01 Aug 2008) | 2 lines
Fix the handling of non-ASCII input in quickstart.
........
r65377 | georg.brandl | 2008-08-01 19:48:24 +0000 (Fri, 01 Aug 2008) | 2 lines
Allow REs in markup checks.
........
r65380 | georg.brandl | 2008-08-01 20:31:18 +0000 (Fri, 01 Aug 2008) | 2 lines
Don't rely on mtimes being different for changed files.
........
r65483 | georg.brandl | 2008-08-04 09:01:40 +0000 (Mon, 04 Aug 2008) | 4 lines
Add an "encoding" option to literalinclude.
Add tests for include directives.
........
r65484 | georg.brandl | 2008-08-04 09:11:17 +0000 (Mon, 04 Aug 2008) | 2 lines
Add changelog entry.
........
r65485 | georg.brandl | 2008-08-04 09:21:58 +0000 (Mon, 04 Aug 2008) | 2 lines
Fix markup.
........
r65494 | georg.brandl | 2008-08-04 16:34:59 +0000 (Mon, 04 Aug 2008) | 2 lines
Correctly use HTML file suffix in templates.
........
2008-08-04 12:01:15 -05:00
|
|
|
def sprint(*args):
|
|
|
|
sys.stderr.write(' '.join(map(str, args)) + '\n')
|
2010-06-20 15:39:38 -05:00
|
|
|
|
2010-07-28 12:15:04 -05:00
|
|
|
_unicode_literals_re = re.compile(r'u(".*?")|u(\'.*?\')')
|
2010-06-20 15:39:38 -05:00
|
|
|
def remove_unicode_literals(s):
|
|
|
|
return _unicode_literals_re.sub(lambda x: x.group(1) or x.group(2), s)
|
2014-08-03 02:22:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
def find_files(root, suffix=None):
|
|
|
|
for dirpath, dirs, files in os.walk(root, followlinks=True):
|
|
|
|
dirpath = path(dirpath)
|
|
|
|
for f in [f for f in files if not suffix or f.endswith(suffix)]:
|
|
|
|
fpath = dirpath / f
|
|
|
|
yield os.path.relpath(fpath, root)
|