summaryrefslogtreecommitdiff
path: root/tests/test_domain_std.py
diff options
context:
space:
mode:
authorTakayuki Shimizukawa <shimizukawa@gmail.com>2014-08-10 23:47:27 +0900
committerTakayuki Shimizukawa <shimizukawa@gmail.com>2014-08-10 23:47:27 +0900
commit1d65d9cdc600677002ed17e7f07b285dc2925f22 (patch)
tree775ebc30bf532e0b16ce19f7629cdb3278c4c335 /tests/test_domain_std.py
parentd39327d5398a4fe55bb72c9b4dc13dad544cf9d0 (diff)
downloadsphinx-git-1d65d9cdc600677002ed17e7f07b285dc2925f22.tar.gz
rename test files
Diffstat (limited to 'tests/test_domain_std.py')
-rw-r--r--tests/test_domain_std.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/test_domain_std.py b/tests/test_domain_std.py
new file mode 100644
index 000000000..81dbe6a4e
--- /dev/null
+++ b/tests/test_domain_std.py
@@ -0,0 +1,80 @@
+# -*- coding: utf-8 -*-
+"""
+ test_domain_std
+ ~~~~~~~~~~~~~~~
+
+ Tests the std domain
+
+ :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+from docutils import nodes
+
+from sphinx.domains.std import StandardDomain
+from util import mock
+
+
+def test_process_doc_handle_figure_caption():
+ env = mock.Mock(domaindata={})
+ figure_node = nodes.figure(
+ '',
+ nodes.caption('caption text', 'caption text'),
+ )
+ document = mock.Mock(
+ nametypes={'testname': True},
+ nameids={'testname': 'testid'},
+ ids={'testid': figure_node},
+ )
+
+ domain = StandardDomain(env)
+ if 'testname' in domain.data['labels']:
+ del domain.data['labels']['testname']
+ domain.process_doc(env, 'testdoc', document)
+ assert 'testname' in domain.data['labels']
+ assert domain.data['labels']['testname'] == (
+ 'testdoc', 'testid', 'caption text')
+
+
+def test_process_doc_handle_image_parent_figure_caption():
+ env = mock.Mock(domaindata={})
+ img_node = nodes.image('', alt='image alt')
+ figure_node = nodes.figure(
+ '',
+ nodes.caption('caption text', 'caption text'),
+ img_node,
+ )
+ document = mock.Mock(
+ nametypes={'testname': True},
+ nameids={'testname': 'testid'},
+ ids={'testid': img_node},
+ )
+
+ domain = StandardDomain(env)
+ if 'testname' in domain.data['labels']:
+ del domain.data['labels']['testname']
+ domain.process_doc(env, 'testdoc', document)
+ assert 'testname' in domain.data['labels']
+ assert domain.data['labels']['testname'] == (
+ 'testdoc', 'testid', 'caption text')
+
+
+def test_process_doc_handle_table_title():
+ env = mock.Mock(domaindata={})
+ table_node = nodes.table(
+ '',
+ nodes.title('title text', 'title text'),
+ )
+ document = mock.Mock(
+ nametypes={'testname': True},
+ nameids={'testname': 'testid'},
+ ids={'testid': table_node},
+ )
+
+ domain = StandardDomain(env)
+ if 'testname' in domain.data['labels']:
+ del domain.data['labels']['testname']
+ domain.process_doc(env, 'testdoc', document)
+ assert 'testname' in domain.data['labels']
+ assert domain.data['labels']['testname'] == (
+ 'testdoc', 'testid', 'title text')