summaryrefslogtreecommitdiff
path: root/tests/test_directive_code.py
diff options
context:
space:
mode:
authorRay Lehtiniemi <rayl@mail.com>2017-03-11 11:46:03 -0700
committerRay Lehtiniemi <rayl@mail.com>2017-03-11 13:40:47 -0700
commit06b6e07b9832be16c5f23e3a224b60cc4d9a020f (patch)
tree05305e40222452a42aaa99c129179e1faca6f628 /tests/test_directive_code.py
parentc5060079e425bfb60b7db617b598764e54980318 (diff)
downloadsphinx-git-06b6e07b9832be16c5f23e3a224b60cc4d9a020f.tar.gz
Add tests
Signed-off-by: Ray Lehtiniemi <rayl@mail.com>
Diffstat (limited to 'tests/test_directive_code.py')
-rw-r--r--tests/test_directive_code.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py
index f2ca9f040..3ace7fb5f 100644
--- a/tests/test_directive_code.py
+++ b/tests/test_directive_code.py
@@ -454,3 +454,45 @@ def test_literalinclude_classes(app, status, warning):
assert len(literalinclude) > 0
assert 'bar baz' == literalinclude[0].get('classes')
assert 'literal_include' == literalinclude[0].get('names')
+
+
+@pytest.mark.sphinx('xml', testroot='directive-code')
+def test_literalinclude_pydecorators(app, status, warning):
+ app.builder.build(['py-decorators'])
+ et = etree_parse(app.outdir / 'py-decorators.xml')
+ secs = et.findall('./section/section')
+
+ literal_include = secs[0].findall('literal_block')
+ assert len(literal_include) == 3
+
+ actual = literal_include[0].text
+ expect = (
+ '@class_decorator\n'
+ '@other_decorator()\n'
+ 'class TheClass(object):\n'
+ '\n'
+ ' @method_decorator\n'
+ ' @other_decorator()\n'
+ ' def the_method():\n'
+ ' pass\n'
+ )
+ assert actual == expect
+
+ actual = literal_include[1].text
+ expect = (
+ ' @method_decorator\n'
+ ' @other_decorator()\n'
+ ' def the_method():\n'
+ ' pass\n'
+ )
+ assert actual == expect
+
+ actual = literal_include[2].text
+ expect = (
+ '@function_decorator\n'
+ '@other_decorator()\n'
+ 'def the_function():\n'
+ ' pass\n'
+ )
+ assert actual == expect
+