summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTakayuki Shimizukawa <shimizukawa+bitbucket@gmail.com>2014-08-24 11:02:36 +0900
committerTakayuki Shimizukawa <shimizukawa+bitbucket@gmail.com>2014-08-24 11:02:36 +0900
commit514e36e733876ff59219e6a594a535921aafb9f9 (patch)
tree664bc175d55372757afa2ba2ee05a244040570f4 /tests
parent9f99eab62dc5d40e8302d395a8ca0794445ddc43 (diff)
parent3b6930d27d18b2fbedc198293f269f62fb46ed60 (diff)
downloadsphinx-514e36e733876ff59219e6a594a535921aafb9f9.tar.gz
Merged in tk0miya/sphinx (pull request #266)
Rename :filename: option of code-block directive to :caption:
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-directive-code/caption.rst21
-rw-r--r--tests/roots/test-directive-code/index.rst1
-rw-r--r--tests/test_directive_code.py42
3 files changed, 64 insertions, 0 deletions
diff --git a/tests/roots/test-directive-code/caption.rst b/tests/roots/test-directive-code/caption.rst
new file mode 100644
index 00000000..274d0f19
--- /dev/null
+++ b/tests/roots/test-directive-code/caption.rst
@@ -0,0 +1,21 @@
+Dedent
+======
+
+Code blocks
+-----------
+
+.. code-block:: ruby
+ :caption: caption-test.rb
+
+ def ruby?
+ false
+ end
+
+
+Literal Include
+---------------
+
+.. literalinclude:: literal.inc
+ :language: python
+ :caption: caption-test.py
+ :lines: 10-11
diff --git a/tests/roots/test-directive-code/index.rst b/tests/roots/test-directive-code/index.rst
index ac7e519e..dab6b708 100644
--- a/tests/roots/test-directive-code/index.rst
+++ b/tests/roots/test-directive-code/index.rst
@@ -2,6 +2,7 @@ test-directive-code
===================
.. toctree::
+ :glob:
*
diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py
index b0da9a04..4dbdff88 100644
--- a/tests/test_directive_code.py
+++ b/tests/test_directive_code.py
@@ -77,6 +77,27 @@ def test_code_block_dedent(app):
assert actual == '\n\n'
+@with_app(buildername='html',
+ srcdir=(test_roots / 'test-directive-code'),
+ _copy_to_temp=True)
+def test_code_block_caption_html(app):
+ app.builder.build('index')
+ html = (app.outdir / 'caption.html').text()
+ caption = '<div class="code-block-caption"><code>caption-test.rb</code></div>'
+ assert caption in html
+
+
+@with_app(buildername='latex',
+ srcdir=(test_roots / 'test-directive-code'),
+ _copy_to_temp=True)
+def test_code_block_caption_latex(app):
+ app.builder.build('index')
+ latex = (app.outdir / 'Python.tex').text()
+ caption = ('{\\colorbox[rgb]{0.9,0.9,0.9}{\\makebox[\\textwidth][l]'
+ '{\\small\\texttt{caption-test.rb}}}}')
+ assert caption in latex
+
+
@with_app(buildername='xml',
srcdir=(test_roots / 'test-directive-code'),
_copy_to_temp=True)
@@ -129,3 +150,24 @@ def test_literal_include_dedent(app):
actual = get_dedent_actual(1000)
assert actual == '\n\n'
+
+
+@with_app(buildername='html',
+ srcdir=(test_roots / 'test-directive-code'),
+ _copy_to_temp=True)
+def test_literalinclude_caption_html(app):
+ app.builder.build('index')
+ html = (app.outdir / 'caption.html').text()
+ caption = '<div class="code-block-caption"><code>caption-test.py</code></div>'
+ assert caption in html
+
+
+@with_app(buildername='latex',
+ srcdir=(test_roots / 'test-directive-code'),
+ _copy_to_temp=True)
+def test_literalinclude_caption_latex(app):
+ app.builder.build('index')
+ latex = (app.outdir / 'Python.tex').text()
+ caption = ('{\\colorbox[rgb]{0.9,0.9,0.9}{\\makebox[\\textwidth][l]'
+ '{\\small\\texttt{caption-test.py}}}}')
+ assert caption in latex