From c3ddb2d17fe373b8628832bbcd98a2dd76b5c31d Mon Sep 17 00:00:00 2001 From: milde Date: Mon, 20 Sep 2021 13:03:39 +0000 Subject: Skip system_messages when propagating targets. Fixes bug #425. Testing with "alltests.py" is currently impossible due to caching (see itest_hyperlinks_de.py) git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8831 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- .../test/test_transforms/itest_hyperlinks_de.py | 76 ++++++++++++++++++++++ docutils/test/test_transforms/test_hyperlinks.py | 9 ++- 2 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 docutils/test/test_transforms/itest_hyperlinks_de.py (limited to 'docutils/test/test_transforms') diff --git a/docutils/test/test_transforms/itest_hyperlinks_de.py b/docutils/test/test_transforms/itest_hyperlinks_de.py new file mode 100644 index 000000000..77c32439c --- /dev/null +++ b/docutils/test/test_transforms/itest_hyperlinks_de.py @@ -0,0 +1,76 @@ +#! /usr/bin/env python + +# $Id$ +# Author: David Goodger +# Copyright: This module has been placed in the public domain. + +""" +Tests for docutils.transforms.references.Hyperlinks with non-English language. + +TODO: This test fails currently when run as part of "alltests" because + + - the "info" system-messages for directive fallbacks are only generated + once (the name -> directive mapping is cached in + ``docutils.parsers.rst.directives._directives``). + + - the cache is not reset between after processing a document + (i.e. it contains name -> directive mappings from other tests). + + See also https://sourceforge.net/p/docutils/feature-requests/71/ +""" + +from __future__ import absolute_import + +if __name__ == '__main__': + import __init__ +from test_transforms import DocutilsTestSupport +from docutils.transforms.references import PropagateTargets, \ + AnonymousHyperlinks, IndirectHyperlinks, ExternalTargets, \ + InternalTargets, DanglingReferences +from docutils.parsers.rst import Parser, directives + +def suite(): + parser = Parser() + settings = {} + settings['language_code'] = 'de' + s = DocutilsTestSupport.TransformTestSuite( + parser, suite_settings=settings) + s.generateTests(totest) + return s + +totest = {} + +totest['hyperlinks'] = ((PropagateTargets, AnonymousHyperlinks, + IndirectHyperlinks, ExternalTargets, + InternalTargets, DanglingReferences), [ + +["""\ +Target_ should propagate past the system_message to set "id" on note. + +.. _target: +.. note:: Kurznotiz + :name: mynote +""", +"""\ + + + + Target + should propagate past the system_message to set "id" on note. + + + + No directive entry for "note" in module "docutils.parsers.rst.languages.de". + Using English fallback for directive "note". + + + Kurznotiz + + + Using for language "de". +"""], +]) + +if __name__ == '__main__': + import unittest + unittest.main(defaultTest='suite') diff --git a/docutils/test/test_transforms/test_hyperlinks.py b/docutils/test/test_transforms/test_hyperlinks.py index 8ec258d16..b20b05284 100755 --- a/docutils/test/test_transforms/test_hyperlinks.py +++ b/docutils/test/test_transforms/test_hyperlinks.py @@ -30,9 +30,8 @@ totest = {} # target/reference, direct/indirect, internal/external, and named/anonymous, # plus embedded URIs. totest['exhaustive_hyperlinks'] = ((PropagateTargets, AnonymousHyperlinks, - IndirectHyperlinks, - ExternalTargets, InternalTargets, - DanglingReferences), [ + IndirectHyperlinks, ExternalTargets, + InternalTargets, DanglingReferences), [ ["""\ direct_ external @@ -185,7 +184,7 @@ Direct internal reference: Implicit_ internal - Direct internal reference: + Direct internal reference: \n\ Implicit_ @@ -840,7 +839,7 @@ Testing an `indirect reference to the table of contents`_. Section <paragraph> - Testing an + Testing an \n\ <reference name="indirect reference to the table of contents" refid="table-of-contents"> indirect reference to the table of contents . -- cgit v1.2.1