Refactor integration tests

pull/13/head
Eric Holscher 9 years ago
parent 627e6d49b4
commit e881072e84

@ -3,91 +3,55 @@ import shutil
import subprocess as sp import subprocess as sp
import unittest import unittest
__author__ = 'swenson' from sphinx.application import Sphinx
class LanguageIntegrationTests(unittest.TestCase): class LanguageIntegrationTests(unittest.TestCase):
def test_full_py(self): tests = (
os.chdir('tests/pyexample') (
try: 'pyexample',
if os.path.exists('_build'): '_build/text/autoapi/example/index.txt',
shutil.rmtree('_build') 'Compute the square root of x and return it'
os.mkdir('_build') ),
sp.check_call('sphinx-build -b text -d _build/doctrees . _build/text', shell=True) (
'jsexample',
with open('_build/text/autoapi/example/index.txt') as fin: '_build/text/autoapi/Circle/index.txt',
text = fin.read().strip() 'Creates an instance of Circle'
self.assertIn('Compute the square root of x and return it.', text) ),
finally: (
os.chdir('../..') 'goexample',
'_build/text/autoapi/main/index.txt',
def test_full_js(self): 'CopyFuncs produces a json-annotated array of Func objects'
os.chdir('tests/jsexample') ),
try: (
if os.path.exists('_build'): 'dotnetexample',
shutil.rmtree('_build') '_build/text/autoapi/Microsoft/CodeAnalysis/AdhocWorkspace/index.txt',
os.mkdir('_build') 'A workspace that allows full manipulation of projects and documents'
sp.check_call('sphinx-build -b text -d _build/doctrees . _build/text', shell=True) ),
(
with open('_build/text/autoapi/Circle/index.txt') as fin: 'templateexample',
text = fin.read().strip() '_build/text/autoapi/example/index.txt',
self.assertIn('Creates an instance of Circle', text) 'This is a fuction template override'
finally: ),
os.chdir('../..') )
def test_full_go(self): def test_basic_integration(self):
os.chdir('tests/goexample') for test_dir, test_file, test_string in self.tests:
try: os.chdir('tests/{0}'.format(test_dir))
if os.path.exists('_build'): try:
shutil.rmtree('_build') app = Sphinx(
os.mkdir('_build') srcdir='.',
sp.check_call('sphinx-build -b text -d _build/doctrees . _build/text', shell=True) confdir='.',
outdir='_build/text',
with open('_build/text/autoapi/main/index.txt') as fin: doctreedir='_build/.doctrees',
text = fin.read().strip() buildername='text',
self.assertIn(
'CopyFuncs produces a json-annotated array of Func objects',
text
) )
finally: app.build(force_all=True)
os.chdir('../..') with open(test_file) as fin:
text = fin.read().strip()
def test_full_dotnet(self): self.assertIn(test_string, text)
os.chdir('tests/dotnetexample') finally:
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/Microsoft/CodeAnalysis/AdhocWorkspace/index.txt') as fin:
text = fin.read().strip()
self.assertIn(
'A workspace that allows full manipulation of projects and documents',
text
)
finally:
os.chdir('../..')
class FeatureIntegrationTests(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') shutil.rmtree('_build')
os.mkdir('_build') os.chdir('../..')
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('../..')

Loading…
Cancel
Save