Add holistic Python test that runs sphinx and EVERYTHING

This commit is contained in:
Christopher Swenson 2015-05-29 14:29:56 -07:00
parent eb05b7d991
commit 817b184619
4 changed files with 87 additions and 0 deletions

21
tests/pyexample/conf.py Normal file
View File

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
project = u'pyexample'
copyright = u'2015, rtfd'
author = u'rtfd'
version = '0.1'
release = '0.1'
language = None
exclude_patterns = ['_build']
pygments_style = 'sphinx'
todo_include_todos = False
html_theme = 'alabaster'
html_static_path = ['_static']
htmlhelp_basename = 'pyexampledoc'
extensions = ['autoapi.extension']
autoapi_type = 'python'
autoapi_dir = 'example'
autoapi_file_pattern = '*.py'

View File

@ -0,0 +1,7 @@
__author__ = 'swenson'
import math
def example_function(x):
"""Compute the square root of x and return it."""
return math.sqrt(x)

26
tests/pyexample/index.rst Normal file
View File

@ -0,0 +1,26 @@
.. pyexample documentation master file, created by
sphinx-quickstart on Fri May 29 13:34:37 2015.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to pyexample's documentation!
=====================================
.. toctree::
autoapi/index
Contents:
.. toctree::
:maxdepth: 2
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

33
tests/test_python_full.py Normal file
View File

@ -0,0 +1,33 @@
__author__ = 'swenson'
import os
import shutil
import subprocess as sp
import unittest
class FullPythonTests(unittest.TestCase):
def test_full_run(self):
os.chdir('tests/pyexample')
try:
if os.path.exists('_build'):
shutil.rmtree('_build')
os.mkdir('_build')
sp.check_call('sphinx-build -b text -d ./doctrees . _build/text', shell=True)
with open('_build/text/autoapi/example/index.txt') as fin:
text = fin.read().strip()
self.assertEquals(text, '''example
*******
Function
========
example.example_function()
Compute the square root of x and return it.''')
finally:
os.chdir('../..')