Commit a6d24663 authored by Sandro Tosi's avatar Sandro Tosi

import sphinxtesters_0.1.1.orig.tar.xz

parents
.. _license:
**********************
Copyright and Licenses
**********************
sphinxtesters
=============
The sphinxtesters package, including all examples, code snippets and attached
documentation is covered by the 2-clause BSD license.
Copyright (c) 2017, Matthew Brett
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include versioneer.py
include sphinxtesters/_version.py
include README.rst
include LICENSE
include *requirements.txt
recursive-include sphinxtesters/tests/proj1 *
recursive-include sphinxtesters/tests/data *
recursive-include sphinxtesters/tests/rst_md_files *
recursive-include sphinxtesters/tests/otherpages *
Metadata-Version: 1.1
Name: sphinxtesters
Version: 0.1.1
Summary: Utilities for testing Sphinx extensions
Home-page: http://github.com/matthew-brett/sphinxtesters
Author: Matthew Brett
Author-email: matthew.brett@gmail.com
License: BSD license
Description: #######################################################
Sphinxtesters - utilities for testing Sphinx extensions
#######################################################
.. shared-text-body
**********
Quickstart
**********
See the tests for examples of using Sphinxtesters for testing builds of Sphinx
projects.
************
Installation
************
::
pip install sphinxtesters
****
Code
****
See https://github.com/matthew-brett/sphinxtesters
Released under the BSD two-clause license - see the file ``LICENSE`` in the
source distribution.
`travis-ci <https://travis-ci.org/matthew-brett/sphinxtesters>`_ kindly tests the
code automatically under Python versions 2.7, and 3.3 through 3.6.
The latest released version is at https://pypi.python.org/pypi/sphinxtesters
*****
Tests
*****
* Install ``sphinxtesters``
* Install the nose_ testing framework::
pip install nose
* Run the tests with::
nosetests sphinxtesters
*******
Support
*******
Please put up issues on the `sphinxtesters issue tracker`_.
.. standalone-references
.. |sphinxtesters-documentation| replace:: `sphinxtesters documentation`_
.. _sphinxtesters documentation:
https://matthew-brett.github.com/sphinxtesters/sphinxtesters.html
.. _documentation: https://matthew-brett.github.com/sphinxtesters
.. _pandoc: http://pandoc.org
.. _jupyter: jupyter.org
.. _homebrew: brew.sh
.. _sphinx: http://sphinx-doc.org
.. _rest: http://docutils.sourceforge.net/rst.html
.. _sphinxtesters issue tracker: https://github.com/matthew-brett/sphinxtesters/issues
.. _nose: http://readthedocs.org/docs/nose/en/latest
.. _mock: https://github.com/testing-cabal/mock
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS
#######################################################
Sphinxtesters - utilities for testing Sphinx extensions
#######################################################
.. shared-text-body
**********
Quickstart
**********
See the tests for examples of using Sphinxtesters for testing builds of Sphinx
projects.
************
Installation
************
::
pip install sphinxtesters
****
Code
****
See https://github.com/matthew-brett/sphinxtesters
Released under the BSD two-clause license - see the file ``LICENSE`` in the
source distribution.
`travis-ci <https://travis-ci.org/matthew-brett/sphinxtesters>`_ kindly tests the
code automatically under Python versions 2.7, and 3.3 through 3.6.
The latest released version is at https://pypi.python.org/pypi/sphinxtesters
*****
Tests
*****
* Install ``sphinxtesters``
* Install the nose_ testing framework::
pip install nose
* Run the tests with::
nosetests sphinxtesters
*******
Support
*******
Please put up issues on the `sphinxtesters issue tracker`_.
.. standalone-references
.. |sphinxtesters-documentation| replace:: `sphinxtesters documentation`_
.. _sphinxtesters documentation:
https://matthew-brett.github.com/sphinxtesters/sphinxtesters.html
.. _documentation: https://matthew-brett.github.com/sphinxtesters
.. _pandoc: http://pandoc.org
.. _jupyter: jupyter.org
.. _homebrew: brew.sh
.. _sphinx: http://sphinx-doc.org
.. _rest: http://docutils.sourceforge.net/rst.html
.. _sphinxtesters issue tracker: https://github.com/matthew-brett/sphinxtesters/issues
.. _nose: http://readthedocs.org/docs/nose/en/latest
.. _mock: https://github.com/testing-cabal/mock
# Requirements for building docs
-r requirements.txt
ghp-import
numpydoc
# Minimum requirements
#
sphinx>=1.4
[versioneer]
vcs = git
style = pep440
versionfile_source = sphinxtesters/_version.py
versionfile_build = sphinxtesters/_version.py
tag_prefix =
parentdir_prefix = sphinxtesters-
[egg_info]
tag_build =
tag_date = 0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
''' Installation script for sphinxtesters package '''
import os
from os.path import join as pjoin, split as psplit, splitext
import re
import setuptools
from distutils.core import setup
import versioneer
# Get install requirements from requirements.txt file
with open('requirements.txt', 'rt') as fobj:
install_requires = [line.strip() for line in fobj
if line.strip() and not line[0] in '#-']
# Get any extra test requirements
with open('test-requirements.txt', 'rt') as fobj:
test_requires = [line.strip() for line in fobj
if line.strip() and not line[0] in '#-']
# Requires for distutils (only used in pypi interface?)
break_ver = re.compile(r'(\S+?)(\[\S+\])?([=<>!]+\S+)')
requires = [break_ver.sub(r'\1 (\3)', req) for req in install_requires]
cmdclass = versioneer.get_cmdclass()
setup(name='sphinxtesters',
version=versioneer.get_version(),
cmdclass=cmdclass,
description='Utilities for testing Sphinx extensions',
author='Matthew Brett',
author_email='matthew.brett@gmail.com',
maintainer='Matthew Brett',
maintainer_email='matthew.brett@gmail.com',
url='http://github.com/matthew-brett/sphinxtesters',
packages=['sphinxtesters',
'sphinxtesters.tests'],
package_data = {'sphinxtesters': [
'tests/data/*.rst',
'tests/rst_md_files/*',
'tests/data/*',
'tests/proj1/*.rst',
'tests/proj1/*.py',
'tests/proj1/_static/*',
'tests/otherpages/*',
]},
license='BSD license',
classifiers = [
'Development Status :: 2 - Pre-Alpha',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Operating System :: MacOS',
],
long_description = open('README.rst', 'rt').read(),
extras_require = {'test': test_requires}
)
Metadata-Version: 1.1
Name: sphinxtesters
Version: 0.1.1
Summary: Utilities for testing Sphinx extensions
Home-page: http://github.com/matthew-brett/sphinxtesters
Author: Matthew Brett
Author-email: matthew.brett@gmail.com
License: BSD license
Description: #######################################################
Sphinxtesters - utilities for testing Sphinx extensions
#######################################################
.. shared-text-body
**********
Quickstart
**********
See the tests for examples of using Sphinxtesters for testing builds of Sphinx
projects.
************
Installation
************
::
pip install sphinxtesters
****
Code
****
See https://github.com/matthew-brett/sphinxtesters
Released under the BSD two-clause license - see the file ``LICENSE`` in the
source distribution.
`travis-ci <https://travis-ci.org/matthew-brett/sphinxtesters>`_ kindly tests the
code automatically under Python versions 2.7, and 3.3 through 3.6.
The latest released version is at https://pypi.python.org/pypi/sphinxtesters
*****
Tests
*****
* Install ``sphinxtesters``
* Install the nose_ testing framework::
pip install nose
* Run the tests with::
nosetests sphinxtesters
*******
Support
*******
Please put up issues on the `sphinxtesters issue tracker`_.
.. standalone-references
.. |sphinxtesters-documentation| replace:: `sphinxtesters documentation`_
.. _sphinxtesters documentation:
https://matthew-brett.github.com/sphinxtesters/sphinxtesters.html
.. _documentation: https://matthew-brett.github.com/sphinxtesters
.. _pandoc: http://pandoc.org
.. _jupyter: jupyter.org
.. _homebrew: brew.sh
.. _sphinx: http://sphinx-doc.org
.. _rest: http://docutils.sourceforge.net/rst.html
.. _sphinxtesters issue tracker: https://github.com/matthew-brett/sphinxtesters/issues
.. _nose: http://readthedocs.org/docs/nose/en/latest
.. _mock: https://github.com/testing-cabal/mock
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS
LICENSE
MANIFEST.in
README.rst
doc-requirements.txt
requirements.txt
setup.cfg
setup.py
test-requirements.txt
versioneer.py
sphinxtesters/__init__.py
sphinxtesters/_version.py
sphinxtesters/sphinxutils.py
sphinxtesters/tmpdirs.py
sphinxtesters.egg-info/PKG-INFO
sphinxtesters.egg-info/SOURCES.txt
sphinxtesters.egg-info/dependency_links.txt
sphinxtesters.egg-info/requires.txt
sphinxtesters.egg-info/top_level.txt
sphinxtesters/tests/__init__.py
sphinxtesters/tests/test_modified_pagebuilder.py
sphinxtesters/tests/test_pagebuilder.py
sphinxtesters/tests/test_proj1.py
sphinxtesters/tests/test_sources_builder.py
sphinxtesters/tests/test_testapp.py
sphinxtesters/tests/test_tmpdirs.py
sphinxtesters/tests/proj1/.gitignore
sphinxtesters/tests/proj1/README.md
sphinxtesters/tests/proj1/a_page.rst
sphinxtesters/tests/proj1/conf.py
sphinxtesters/tests/proj1/index.rst
sphinxtesters/tests/proj1/_static/.gitignore
sphinxtesters/tests/proj1/_static/README.txt
\ No newline at end of file
""" Sphinxtesters package
"""
from .sphinxutils import (SourcesBuilder, ModifiedPageBuilder, TempApp)
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
# This file was generated by 'versioneer.py' (0.18) from
# revision-control system data, or from the parent directory name of an
# unpacked source archive. Distribution tarballs contain a pre-generated copy
# of this file.
import json
version_json = '''
{
"date": "2017-08-31T17:21:43+0100",
"dirty": false,
"error": null,
"full-revisionid": "5c6a22fbc9da79a664c16d5157948e8d485bfaa1",
"version": "0.1.1"
}
''' # END VERSION_JSON
def get_versions():
return json.loads(version_json)
This diff is collapsed.
# Test project
A minimal Sphinx project.
###############################
Static directory for test pages
###############################
We need this README file to make sure the ``_static`` directory gets created
in the installation. The tests check for warnings in builds, and, when the
``_static`` directory is absent, this raises a warning.
#########
A section
#########
Some text.
More text.
Text is endless.
# The master toctree document.
master_doc = 'index'
Here start the pages
====================
Contents:
.. toctree::
:maxdepth: 2
a_page
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
""" Test ModifiedPageBuilder
"""
from io import StringIO
from os.path import dirname, join as pjoin
from sphinxtesters.sphinxutils import ModifiedPageBuilder
from sphinxtesters.tmpdirs import in_dtemp
from nose.tools import assert_equal, assert_raises
HERE = dirname(__file__)
PROJ1 = pjoin(HERE, 'proj1')
NEW_PAGE = u"""
Fancy title
+++++++++++
Compelling text
"""
class TestModifiedPageBuilder(ModifiedPageBuilder):
# Replace page with file-like object
page_source_template = PROJ1
default_page = 'a_page'
_new_page = u"""
Fancy title
+++++++++++
Compelling text
"""
@classmethod
def modify_source(cls):
page_fobj = StringIO(cls._new_page)
cls.replace_page(page_fobj)
def test_a_build(self):
doctree = self.get_doctree(self.default_page)
doctree_str = self.doctree2str(doctree)
expected = (
'<title>Fancy title</title>\n'
'<paragraph>Compelling text</paragraph>')
assert_equal(doctree_str, expected)
class TestFModifiedPageBuilder(TestModifiedPageBuilder):
# Replace page, but with filename
@classmethod
def modify_source(cls):
with in_dtemp():
with open('test.txt', 'wt') as fobj:
fobj.write(cls._new_page)
cls.replace_page('test.txt')
def test_bad_pagebuilder():
""" Tests that warning on build generates error
"""
class TestBadPageBuilder(TestModifiedPageBuilder):
_new_page = u"""
Fancy title
+++++++++++
:ref:`not-a-target`
"""
assert_raises(RuntimeError, TestBadPageBuilder.setup_class)
class TestAppendConf(TestModifiedPageBuilder):
# Test append_conf method
@classmethod
def modify_source(cls):
super(TestAppendConf, cls).modify_source()
cls.append_conf('# Spurious comment')
def test_append_conf(self):
with open(pjoin(PROJ1, 'conf.py'), 'rt') as fobj:
before_contents = fobj.read()
with open(pjoin(self.page_source, 'conf.py'), 'rt') as fobj:
after_contents = fobj.read()
assert_equal(after_contents, before_contents + '# Spurious comment')
class TestAddPage(TestModifiedPageBuilder):
# Test ability to add a page
@classmethod
def modify_source(cls):
page_fobj = StringIO(cls._new_page)
cls.add_page(page_fobj, 'b_page')
def test_a_build(self):
doctree = self.get_doctree(self.default_page)
doctree_str = self.doctree2str(doctree)
expected = (
'<title>A section</title>\n'
'<paragraph>Some text.</paragraph>\n'
'<paragraph>More text.</paragraph>\n'
'<paragraph>Text is endless.</paragraph>')
assert_equal(doctree_str, expected)
expected = (
'<title>Fancy title</title>\n'
'<paragraph>Compelling text</paragraph>')
doctree = self.get_doctree('b_page')
doctree_str = self.doctree2str(doctree)
assert_equal(doctree_str, expected)
class TestAddFPage(TestAddPage):
# Test ability to add a page as filename
@classmethod
def modify_source(cls):
with in_dtemp():
with open('test.txt', 'wt') as fobj:
fobj.write(cls._new_page)
cls.add_page('test.txt', 'b_page')
""" Test PageBuilder
"""
from os.path import (dirname, join as pjoin, isdir, isfile)
from sphinxtesters.sphinxutils import PageBuilder
from nose.tools import assert_true, assert_equal, assert_raises
HERE = dirname(__file__)
PROJ1 = pjoin(HERE, 'proj1')
class TestPageBuilder(PageBuilder):
@classmethod
def set_page_source(cls):
cls.page_source = PROJ1
def test_basic_build(self):
assert_true(isdir(self.out_dir))
assert_true(isdir(self.doctree_dir))
doctree = self.get_doctree('a_page')
assert_equal(len(doctree.document), 1)
doctree_str = self.doctree2str(doctree)
expected = (
'<title>A section</title>\n'
'<paragraph>Some text.</paragraph>\n'
'<paragraph>More text.</paragraph>\n'
'<paragraph>Text is endless.</paragraph>')
assert_equal(doctree_str, expected)
assert_true(isfile(pjoin(self.doctree_dir, 'index.doctree')))
html = self.get_built_file('a_page.html')
assert_true('Text is endless' in html)
def test_bad_pagebuilder():
class TestBadPageBuilder(PageBuilder):
@classmethod
def set_page_source(cls):
cls.page_source = HERE
assert_raises(IOError, TestBadPageBuilder.setup_class)
""" Tests for proj1 build using sphinx extensions """
from os.path import (join as pjoin, dirname, isdir, exists, splitext)
from sphinxtesters import ModifiedPageBuilder
from nose.tools import assert_true, assert_equal
HERE = dirname(__file__)
class Proj1Builder(ModifiedPageBuilder):
""" Build using 'proj1' directory as template to modify
"""
page_source_template = pjoin(HERE, 'proj1')
# default_page used in 'replace_page' class method
default_page = 'a_page.rst'
class TestProj1(Proj1Builder):
def test_basic_build(self):
assert_true(isdir(self.out_dir))
assert_true(isdir(self.doctree_dir))
doctree = self.get_doctree(splitext(self.default_page)[0])
assert_equal(len(doctree.document), 1)
doctree_str = self.doctree2str(doctree)
expected = (
'<title>A section</title>\n'
'<paragraph>Some text.</paragraph>\n'
'<paragraph>More text.</paragraph>\n'
'<paragraph>Text is endless.</paragraph>')
assert_equal(doctree_str, expected)
assert_true(exists(pjoin(self.doctree_dir, 'index.doctree')))
""" Tests for SourcesBuilder utility
"""
from os.path import (join as pjoin, dirname, isdir, exists)
from sphinxtesters import SourcesBuilder
from nose.tools import assert_true, assert_equal
A_PAGE = """\
#########
A section
#########
Some text.
More text.
Text is endless."""
A_DOCTREE = """\
<title>A section</title>
<paragraph>Some text.</paragraph>
<paragraph>More text.</paragraph>
<paragraph>Text is endless.</paragraph>"""
B_PAGE = """\