2015-05-29 21:29:56 +00:00
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import subprocess as sp
|
|
|
|
import unittest
|
|
|
|
|
2015-06-06 20:20:11 +00:00
|
|
|
__author__ = 'swenson'
|
|
|
|
|
2015-05-29 21:29:56 +00:00
|
|
|
|
|
|
|
class FullPythonTests(unittest.TestCase):
|
|
|
|
|
2015-06-06 20:19:08 +00:00
|
|
|
def test_full_py(self):
|
2015-05-29 21:29:56 +00:00
|
|
|
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)
|
2015-05-29 21:29:56 +00:00
|
|
|
|
|
|
|
with open('_build/text/autoapi/example/index.txt') as fin:
|
|
|
|
text = fin.read().strip()
|
2015-06-06 23:11:49 +00:00
|
|
|
self.assertIn('Compute the square root of x and return it.', text)
|
2015-05-29 21:29:56 +00:00
|
|
|
finally:
|
|
|
|
os.chdir('../..')
|
2015-06-06 20:08:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FullJavaScriptTests(unittest.TestCase):
|
|
|
|
|
2015-06-06 20:19:08 +00:00
|
|
|
def test_full_js(self):
|
2015-06-06 20:08:44 +00:00
|
|
|
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)
|
2015-06-06 20:08:44 +00:00
|
|
|
|
|
|
|
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('../..')
|