sphinx-autoapi/tests/test_full.py

63 lines
1.9 KiB
Python
Raw Normal View History

import os
import shutil
import subprocess as sp
import unittest
2015-06-06 20:20:11 +00:00
__author__ = 'swenson'
class FullPythonTests(unittest.TestCase):
2015-06-06 20:19:08 +00:00
def test_full_py(self):
os.chdir('tests/pyexample')
try:
if os.path.exists('_build'):
shutil.rmtree('_build')
os.mkdir('_build')
2015-06-10 17:33:18 +00:00
sp.check_call('sphinx-build -b text -d _build/doctrees . _build/text', shell=True)
with open('_build/text/autoapi/example/index.txt') as fin:
text = fin.read().strip()
self.assertIn('Compute the square root of x and return it.', text)
finally:
os.chdir('../..')
class FullJavaScriptTests(unittest.TestCase):
2015-06-06 20:19:08 +00:00
def test_full_js(self):
os.chdir('tests/jsexample')
try:
if os.path.exists('_build'):
shutil.rmtree('_build')
os.mkdir('_build')
2015-06-10 17:33:18 +00:00
sp.check_call('sphinx-build -b text -d _build/doctrees . _build/text', shell=True)
with open('_build/text/autoapi/Circle/index.txt') as fin:
text = fin.read().strip()
self.assertIn('Creates an instance of Circle', text)
finally:
os.chdir('../..')
2015-06-10 17:33:18 +00:00
class FullTemplateTests(unittest.TestCase):
def test_template_override(self):
"""
Test that we are overriding the template properly.
This uses the ``template_overrides/python/function.rst`` template to override content.
"""
os.chdir('tests/templateexample')
try:
if os.path.exists('_build'):
shutil.rmtree('_build')
os.mkdir('_build')
sp.check_call('sphinx-build -b text -d _build/doctrees . _build/text', shell=True)
with open('_build/text/autoapi/example/index.txt') as fin:
text = fin.read().strip()
self.assertIn('This is a fuction template override!', text)
finally:
os.chdir('../..')