def suite():
    settings = {'template': os.path.join(DocutilsTestSupport.testroot,
                                         'data', 'full-template.txt'),
                'embed_stylesheet': 0,}
    s = DocutilsTestSupport.PublishTestSuite('html', suite_settings=settings)
    s.generateTests(totest)
    return s
Example #2
0
def suite():
    parser = Parser()
    s = DocutilsTestSupport.TransformTestSuite(
        parser,
        suite_settings={'strip_elements_with_classes': ['spam', 'no-ham']})
    s.generateTests(totest)
    return s
Example #3
0
def suite():
    settings = {'embed_stylesheet': 0,}
    s = DocutilsTestSupport.PublishTestSuite('s5', suite_settings=settings)
    s.generateTests(totest_1)
    settings['hidden_controls'] = 0
    settings['view_mode'] = 'outline'
    s.generateTests(totest_2)
    return s
def suite():
    settings = {
        'language_code': 'local-dummy-lang',
        'report_level': 2
    }  # warning (has no effect on test output is run as __main__).
    s = DocutilsTestSupport.ParserTestSuite(suite_settings=settings)
    s.generateTests(totest)
    return s
def suite():
    parser = Parser()
    settings = {'language_code': 'en'}
    s = DocutilsTestSupport.TransformTestSuite(parser, suite_settings=settings)
    s.generateTests(totest)
    settings['language_code'] = 'de'
    s.generateTests(totest_de)
    settings['language_code'] = 'ru'
    s.generateTests(totest_ru)
    return s
def suite():
    parser = Parser()
    settings = {'smart_quotes': True}
    s = DocutilsTestSupport.TransformTestSuite(parser, suite_settings=settings)
    s.generateTests(totest)
    settings['language_code'] = 'de'
    s.generateTests(totest_de)
    settings['smart_quotes'] = 'alternative'
    s.generateTests(totest_de_alt)
    return s
Example #7
0
def suite():
    parser = Parser()
    settings = {'smart_quotes': True}
    s = DocutilsTestSupport.TransformTestSuite(parser, suite_settings=settings)
    s.generateTests(totest)
    settings['language_code'] = 'de'
    s.generateTests(totest_de)
    settings['smart_quotes'] = 'alternative'
    s.generateTests(totest_de_alt)
    settings['smart_quotes'] = True
    settings['smartquotes_locales'] = [('de', u'«»()'), ('nl', u'„”’’')]
    s.generateTests(totest_locales)
    return s
Example #8
0
def suite():
    settings = {'use_latex_toc': 0}
    s = DocutilsTestSupport.PublishTestSuite('latex', suite_settings=settings)
    s.generateTests(totest)
    settings['use_latex_toc'] = 1
    s.generateTests(totest_latex_toc)
    settings['use_latex_toc'] = 0
    settings['sectnum_xform'] = 0
    s.generateTests(totest_latex_sectnum)
    settings['sectnum_xform'] = 1
    settings['use_latex_citations'] = 1
    s.generateTests(totest_latex_citations)
    return s
Example #9
0
def suite():
    settings = {'use_latex_toc': 0}
    s = DocutilsTestSupport.PublishTestSuite('latex', suite_settings=settings)
    s.generateTests(totest)
    settings['use_latex_toc'] = 1
    s.generateTests(totest_latex_toc)
    settings['use_latex_toc'] = 0
    settings['sectnum_xform'] = 0
    s.generateTests(totest_latex_sectnum)
    settings['sectnum_xform'] = 1
    settings['use_latex_citations'] = 1
    s.generateTests(totest_latex_citations)
    settings['stylesheet_path'] = 'data/spam,data/ham.tex'
    s.generateTests(totest_stylesheet)
    settings['embed_stylesheet'] = 1
    s.generateTests(totest_stylesheet_embed)
    return s
Example #10
0
def suite():
    settings = {'use_latex_toc': False}
    s = DocutilsTestSupport.PublishTestSuite('latex', suite_settings=settings)
    s.generateTests(totest)
    settings['use_latex_toc'] = True
    s.generateTests(totest_latex_toc)
    settings['use_latex_toc'] = False
    settings['sectnum_xform'] = False
    s.generateTests(totest_latex_sectnum)
    settings['sectnum_xform'] = True
    settings['use_latex_citations'] = True
    s.generateTests(totest_latex_citations)
    settings['table_style'] = ['colwidths-auto']
    s.generateTests(totest_table_style_auto)
    settings['table_style'] = ['booktabs']
    s.generateTests(totest_table_style_booktabs)
    settings['stylesheet_path'] = 'data/spam,data/ham.tex'
    s.generateTests(totest_stylesheet)
    settings['embed_stylesheet'] = True
    settings['warning_stream'] = ''
    s.generateTests(totest_stylesheet_embed)
    return s
def suite():
    parser = Parser()
    s = DocutilsTestSupport.TransformTestSuite(
        parser, suite_settings={'expose_internals': ['rawsource', 'source']})
    s.generateTests(totest)
    return s
Example #12
0
            unicode:: 0x111111111111111111
    <system_message level="2" line="2" source="test data" type="WARNING">
        <paragraph>
            Substitution definition "too big for int" empty or invalid.
        <literal_block xml:space="preserve">
            .. |too big for int| unicode:: 0x111111111111111111
    <system_message level="3" line="3" source="test data" type="ERROR">
        <paragraph>
            Invalid character code: 0x11111111
            %s
        <literal_block xml:space="preserve">
            unicode:: 0x11111111
    <system_message level="2" line="3" source="test data" type="WARNING">
        <paragraph>
            Substitution definition "too big for unicode" empty or invalid.
        <literal_block xml:space="preserve">
            .. |too big for unicode| unicode:: 0x11111111
""" % ([DocutilsTestSupport.exception_data(
            'unichr(int("111111111111111111", 16))')[0],
        'code too large (%s)' % DocutilsTestSupport.exception_data(
    'unichr(int("111111111111111111", 16))')[0]]
       [isinstance(DocutilsTestSupport.exception_data(
    'unichr(int("111111111111111111", 16))')[0], OverflowError)],
       DocutilsTestSupport.exception_data('unichr(int("11111111", 16))')[2])]
]


if __name__ == '__main__':
    import unittest
    unittest.main(defaultTest='suite')
Example #13
0
    [
        """\
.. contents::
   :depth: two
""",
        """\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "contents" directive:
            invalid option value: (option: "depth"; value: 'two')
            %s.
        <literal_block xml:space="preserve">
            .. contents::
               :depth: two
""" % DocutilsTestSupport.exception_data(int, "two")[1][0]
    ],
    [
        """\
.. contents::
   :width: 2
""", """\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "contents" directive:
            unknown option: "width".
        <literal_block xml:space="preserve">
            .. contents::
               :width: 2
"""
    [
        """\
.. image:: picture.png
   :scale:
""",
        """\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "image" directive:
            invalid option value: (option: "scale"; value: None)
            %s.
        <literal_block xml:space="preserve">
            .. image:: picture.png
               :scale:
""" % DocutilsTestSupport.exception_data('int(None)')[1][0]
    ],
    [
        """\
.. image:: picture.png
   :scale 50
""", """\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "image" directive:
            invalid option block.
        <literal_block xml:space="preserve">
            .. image:: picture.png
               :scale 50
"""
Example #15
0
    [
        """\
.. image:: picture.png
   :scale:
""",
        """\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "image" directive:
            invalid option value: (option: "scale"; value: None)
            %s.
        <literal_block xml:space="preserve">
            .. image:: picture.png
               :scale:
""" % DocutilsTestSupport.exception_data(int, None)[1][0]
    ],
    [
        """\
.. image:: picture.png
   :height: 100
   :scale 50
""", """\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "image" directive:
            invalid option block.
        <literal_block xml:space="preserve">
            .. image:: picture.png
               :height: 100
Example #16
0
def suite():
    s = DocutilsTestSupport.HtmlPublishPartsTestSuite()
    s.generateTests(totest)
    return s
Example #17
0
def suite():
    s = DocutilsTestSupport.ParserTestSuite()
    s.generateTests(totest)
    return s
Example #18
0
"""],
["""\
.. image:: picture.png
   :scale:
""",
"""\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "image" directive:
            invalid option value: (option: "scale"; value: None)
            %s.
        <literal_block xml:space="preserve">
            .. image:: picture.png
               :scale:
""" % DocutilsTestSupport.exception_data(int, None)[1][0]],
["""\
.. image:: picture.png
   :height: 100
   :scale 50
""",
"""\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "image" directive:
            invalid option block.
        <literal_block xml:space="preserve">
            .. image:: picture.png
               :height: 100
               :scale 50
def suite():
    s = DocutilsTestSupport.PythonModuleParserTestSuite()
    s.generateTests(totest, testmethod='test_token_parser_rhs')
    return s
Example #20
0
def suite():
    parser = Parser()
    s = DocutilsTestSupport.TransformTestSuite(parser)
    s.generateTests(totest)
    return s
Example #21
0
def suite():
    settings = {}
    s = DocutilsTestSupport.PublishTestSuite('manpage',
                                             suite_settings=settings)
    s.generateTests(totest)
    return s
Example #22
0
# Author: David Goodger <*****@*****.**>
# Copyright: This module has been placed in the public domain.

"""
Tests for misc.py "unicode" directive.
"""

from __init__ import DocutilsTestSupport


def suite():
    s = DocutilsTestSupport.ParserTestSuite()
    s.generateTests(totest)
    return s

unichr_exception = DocutilsTestSupport.exception_data(
    'unichr(int("111111111111111111", 16))')[0]
if isinstance(unichr_exception, OverflowError):
    unichr_exception_string = 'code too large (%s)' % unichr_exception
else:
    unichr_exception_string = str(unichr_exception)

totest = {}

totest['unicode'] = [
["""
Insert an em-dash (|mdash|), a copyright symbol (|copy|), a non-breaking
space (|nbsp|), a backwards-not-equals (|bne|), and a captial omega (|Omega|).

.. |mdash| unicode:: 0x02014
.. |copy| unicode:: \\u00A9
.. |nbsp| unicode:: &#x000A0;
def suite():
    parser = Parser()
    s = DocutilsTestSupport.TransformTestSuite(
        parser, suite_settings={'strip_comments': 1})
    s.generateTests(totest)
    return s
Example #24
0
        """\
.. image:: picture.png
   :scale:
""",
        """\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "image" directive:
            invalid option value: (option: "scale"; value: None)
            %s.
        <literal_block xml:space="preserve">
            .. image:: picture.png
               :scale:
"""
        % DocutilsTestSupport.exception_data(int, None)[1][0],
    ],
    [
        """\
.. image:: picture.png
   :height: 100
   :scale 50
""",
        """\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "image" directive:
            invalid option block.
        <literal_block xml:space="preserve">
            .. image:: picture.png
Example #25
0
        <system_message level="3" line="70" source="%(source)s" type="ERROR">
            <paragraph>
                Unknown directive type "unknown".
            <literal_block xml:space="preserve">
                .. unknown:: directive (info still reported with wrong line)
        <system_message level="3" line="72" source="%(source)s" type="ERROR">
            <paragraph>
                Malformed table.
                No bottom table border found.
            <literal_block xml:space="preserve">
                ==============  ======
                A simple table  with
                no bottom       border
""" % {'source': reldir(include10), 'nonexistent': reldir(nonexistent),
       'unichr_exception':
       DocutilsTestSupport.exception_data(unichr, int("11111111", 16))[2]
      }],
["""\
Include file with whitespace in the path:

.. include:: %s
""" % reldir(include11),
"""\
<document source="test data">
    <paragraph>
        Include file with whitespace in the path:
    <paragraph>
        some text
"""],
["""\
Standard include data file:
Example #26
0
import csv
from docutils._compat import u_prefix
from docutils.parsers.rst.directives import tables


def suite():
    s = DocutilsTestSupport.ParserTestSuite()
    s.generateTests(totest)
    return s

mydir = 'test_parsers/test_rst/test_directives/'
utf_16_csv = os.path.join(mydir, 'utf-16.csv')
utf_16_csv_rel = DocutilsTestSupport.utils.relative_path(None, utf_16_csv)
empty_txt = os.path.join(mydir, 'empty.txt')

unichr_exception = DocutilsTestSupport.exception_data(
    unichr, int("9999999999999", 16))[0]
if isinstance(unichr_exception, OverflowError):
    unichr_exception_string = 'code too large (%s)' % unichr_exception
else:
    unichr_exception_string = str(unichr_exception)

def null_bytes():
    import csv
    csv_data = open(utf_16_csv, 'rb').read()
    csv_data = unicode(csv_data, 'latin1').splitlines()
    reader = csv.reader([tables.CSVTable.encode_for_csv(line + '\n')
                         for line in csv_data])
    reader.next()

null_bytes_exception = DocutilsTestSupport.exception_data(null_bytes)[0]
Example #27
0
def suite():
    s = DocutilsTestSupport.PublishTestSuite('pseudoxml')
    s.generateTests(totest)
    return s
from docutils.parsers.rst.directives import tables


def suite():
    s = DocutilsTestSupport.ParserTestSuite()
    s.generateTests(totest)
    return s


mydir = 'test_parsers/test_rst/test_directives/'
utf_16_csv = os.path.join(mydir, 'utf-16.csv')
utf_16_csv_rel = DocutilsTestSupport.utils.relative_path(None, utf_16_csv)
empty_txt = os.path.join(mydir, 'empty.txt')

unichr_exception = DocutilsTestSupport.exception_data(unichr,
                                                      int("9999999999999",
                                                          16))[0]
if isinstance(unichr_exception, OverflowError):
    unichr_exception_string = 'code too large (%s)' % unichr_exception
else:
    unichr_exception_string = str(unichr_exception)

# some error messages changed in Python 3.3:
csv_eod_error_str = 'unexpected end of data'
if sys.version_info < (3, 2, 4) and not (  # backport to 2.7.4
        sys.version_info[:2] == (2, 7) and sys.version_info[2] > 3):
    csv_eod_error_str = 'newline inside string'
csv_unknown_url = "'bogus.csv'"
if sys.version_info < (3, 3, 2):
    csv_unknown_url = "bogus.csv"
Example #29
0
def suite():
    s = DocutilsTestSupport.ParserTestSuite(
        suite_settings={'syntax_highlight': 'long'})
    if with_pygments:
        s.generateTests(totest)
    return s
Example #30
0
"""],
["""\
.. image:: picture.png
   :scale:
""",
"""\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "image" directive:
            invalid option value: (option: "scale"; value: None)
            %s.
        <literal_block xml:space="preserve">
            .. image:: picture.png
               :scale:
""" % DocutilsTestSupport.exception_data('int(None)')[1][0]],
["""\
.. image:: picture.png
   :scale 50
""",
"""\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "image" directive:
            invalid option block.
        <literal_block xml:space="preserve">
            .. image:: picture.png
               :scale 50
"""],
["""\
Example #31
0
            unicode:: 0x111111111111111111
    <system_message level="2" line="2" source="test data" type="WARNING">
        <paragraph>
            Substitution definition "too big for int" empty or invalid.
        <literal_block xml:space="preserve">
            .. |too big for int| unicode:: 0x111111111111111111
    <system_message level="3" line="3" source="test data" type="ERROR">
        <paragraph>
            Invalid character code: 0x11111111
            %s
        <literal_block xml:space="preserve">
            unicode:: 0x11111111
    <system_message level="2" line="3" source="test data" type="WARNING">
        <paragraph>
            Substitution definition "too big for unicode" empty or invalid.
        <literal_block xml:space="preserve">
            .. |too big for unicode| unicode:: 0x11111111
""" % ([DocutilsTestSupport.exception_data(
            'unichr(int("111111111111111111", 16))')[0],
        'code too large (%s)' % DocutilsTestSupport.exception_data(
    'unichr(int("111111111111111111", 16))')[0]]
       [isinstance(DocutilsTestSupport.exception_data(
    'unichr(int("111111111111111111", 16))')[0], OverflowError)],
       DocutilsTestSupport.exception_data('unichr(int("11111111", 16))')[2])]
]


if __name__ == '__main__':
    import unittest
    unittest.main(defaultTest='suite')
def suite():
    s = DocutilsTestSupport.ParserTestSuite(
        suite_settings={'language_code': 'fr'})
    s.generateTests(totest)
    return s
Example #33
0
"""],
["""\
.. contents::
   :depth: two
""",
"""\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "contents" directive:
            invalid option value: (option: "depth"; value: 'two')
            %s.
        <literal_block xml:space="preserve">
            .. contents::
               :depth: two
""" % DocutilsTestSupport.exception_data(int, "two")[1][0]],
["""\
.. contents::
   :width: 2
""",
"""\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "contents" directive:
            unknown option: "width".
        <literal_block xml:space="preserve">
            .. contents::
               :width: 2
"""],
["""\
Example #34
0
def suite():
    s = DocutilsTestSupport.ParserTestSuite(
        suite_settings={'syntax_highlight': 'none'})
    s.generateTests(totest)
    return s
def suite():
    s = DocutilsTestSupport.PythonLatexPublishTestSuite()
    s.generateTests(totest)
    return s
Example #36
0
    import csv
except ImportError:
    csv = None


def suite():
    s = DocutilsTestSupport.ParserTestSuite()
    s.generateTests(totest)
    return s

mydir = 'test_parsers/test_rst/test_directives/'
utf_16_csv = os.path.join(mydir, 'utf-16.csv')
utf_16_csv_rel = DocutilsTestSupport.utils.relative_path(None, utf_16_csv)
empty_txt = os.path.join(mydir, 'empty.txt')

unichr_exception = DocutilsTestSupport.exception_data(
    'unichr(int("9999999999999", 16))')[0]
if isinstance(unichr_exception, OverflowError):
    unichr_exception_string = 'code too large (%s)' % unichr_exception
else:
    unichr_exception_string = str(unichr_exception)

null_bytes_code = """
import csv
import cStringIO
csv_data = open('%s', 'rb').read()
csv_file = cStringIO.StringIO(csv_data)
reader = csv.reader(csv_file)
reader.next()
""" % utf_16_csv
null_bytes_exception = DocutilsTestSupport.exception_data(null_bytes_code)[0]
def suite():
    s = DocutilsTestSupport.ParserTestSuite(
        suite_settings={'character_level_inline_markup': True})
    s.generateTests(totest)
    return s
Example #38
0
def suite():
    s = DocutilsTestSupport.ParserTestSuite()
    if not with_pygments:
        del(totest['include-code'])
    s.generateTests(totest)
    return s
Example #39
0
"""],
["""\
.. contents::
   :depth: two
""",
"""\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "contents" directive:
            invalid option value: (option: "depth"; value: 'two')
            %s.
        <literal_block xml:space="preserve">
            .. contents::
               :depth: two
""" % DocutilsTestSupport.exception_data('int("two")')[1][0]],
["""\
.. contents::
   :width: 2
""",
"""\
<document source="test data">
    <system_message level="3" line="1" source="test data" type="ERROR">
        <paragraph>
            Error in "contents" directive:
            unknown option: "width".
        <literal_block xml:space="preserve">
            .. contents::
               :width: 2
"""],
["""\