From 92c4d879b252e14f73e2e9ace891a7015c29c0c5 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: Thu, 18 Feb 2016 17:03:49 +0100 Subject: [PATCH] Add basic test and doc infrastructure - Use testrepository for testing and add a single, very basic test. - Use the common OpenStack setup to create documentation. Change-Id: I8987e0ae0829edd26f239a85b6a69e2f529a8932 --- .testr.conf | 8 ++++++ doc/source/conf.py | 65 +++++++++++++++++++++++++++++++++++++++++++ doc/source/index.rst | 38 +++++++++++++++++++++++++ test-requirements.txt | 8 +++++- tests.py | 32 +++++++++++++++++++++ tox.ini | 6 +++- 6 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 .testr.conf create mode 100644 doc/source/conf.py create mode 100644 doc/source/index.rst create mode 100644 tests.py diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..6e4d6d0 --- /dev/null +++ b/.testr.conf @@ -0,0 +1,8 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ + OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \ + ${PYTHON:-python} -m subunit.run discover -t ./ ./ $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 0000000..fdb1bfe --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- + +import os +import sys + +sys.path.insert(0, os.path.abspath('../..')) +# -- General configuration ---------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ + 'sphinx.ext.autodoc', + 'oslosphinx', +] + +# autodoc generation is a bit aggressive and a nuisance when doing heavy +# text edit cycles. +# execute "export SPHINX_DEBUG=1" in your terminal to disable + +# Add any paths that contain templates here, relative to this directory. +# templates_path = [] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'renderspec' +copyright = u'2016, OpenStack Foundation' + +# If true, '()' will be appended to :func: etc. cross-reference text. +add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +# html_theme_path = ["."] +# html_theme = '_theme' +html_static_path = ['static'] + +# Output file base name for HTML help builder. +htmlhelp_basename = '%sdoc' % project + +git_cmd = "git log --pretty=format:'%ad, commit %h' --date=local -n1" +html_last_updated_fmt = os.popen(git_cmd).read() + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto/manual]). +latex_documents = [ + ('index', + '%s.tex' % project, + '%s Documentation' % project, + 'OpenStack Foundation', 'manual'), +] diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000..061ecb3 --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,38 @@ +renderspec +========== + +`renderspec` is a python program to render RPM spec file templates to a +usable spec file. Distribution specifics like different policies for +package naming in openSUSE or Fedora are handled. + +Installation +============ + +From PyPI +********* + +For your convenience, `renderspec` is also available from the Cheese +Shop: + +.. code-block:: shell + + pip install renderspec + +From source +*********** + +If you want to hack `renderspec` or just have the latest version without +waiting for next release, use the git repo directly a la + +.. code-block:: shell + + git clone https://git.openstack.org/openstack/renderspec + cd renderspec + python setup.py develop --user + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`search` + diff --git a/test-requirements.txt b/test-requirements.txt index 770c57d..13057b8 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +1,7 @@ -hacking<0.11,>=0.10.0 +flake8 +testrepository>=0.0.18 +testresources>=0.2.4 +testtools>=1.4.0 + +sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 +oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0 diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..50101e0 --- /dev/null +++ b/tests.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +# Copyright (c) 2016 SUSE Linux GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +try: + import unittest2 as unittest +except ImportError: + import unittest + +import renderspec + + +class RenderspecTests(unittest.TestCase): + def test_filter_noop(self): + self.assertEqual(renderspec._filter_noop("foobar"), "foobar") + + +if __name__ == '__main__': + unittest.main() diff --git a/tox.ini b/tox.ini index 494433c..253c2bf 100644 --- a/tox.ini +++ b/tox.ini @@ -10,9 +10,9 @@ setenv = VIRTUAL_ENV={envdir} OS_STDOUT_NOCAPTURE=False OS_STDERR_NOCAPTURE=False PYTHONHASHSEED=0 - deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt +commands = python setup.py testr --testr-args='{posargs}' [testenv:pep8] commands = flake8 @@ -22,3 +22,7 @@ commands = {posargs} [flake8] exclude = .venv,.git,.tox,dist,doc,*openstack/common/*,*lib/python*,*egg,build + +[testenv:docs] +commands = python setup.py build_sphinx +