Skip to content

Commit

Permalink
Modernise testing with testr and tox
Browse files Browse the repository at this point in the history
This enables easier testing across multiple versions of python.

Using this, I've been able to confirm that 117 tests pass on py26 and
py27, with 122 passing on py3.3 and py3.4 (I don't have py3.3 available)

Travis config is now done mostly automatically via tox-travis
  • Loading branch information
jamezpolley committed May 22, 2015
1 parent f562e56 commit c2e2e84
Show file tree
Hide file tree
Showing 5 changed files with 281 additions and 78 deletions.
4 changes: 4 additions & 0 deletions .testr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ python:
- 3.4
- pypy
install:
- pip install -r requirements.txt
- python setup.py install
script:
- coverage run setup.py test
- coverage report --show-missing
after_success:
- coveralls
- pip install tox-travis
notifications:
email: [email protected]
script: tox
305 changes: 239 additions & 66 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,68 +1,241 @@
Changelog
---------

1.0 (Unreleased)
````````````````
* Ensure mock package gets installed on testing.

0.9 (2014-08-02)
````````````````
* First beta release
* Sphinx documentation available on Read The Docs
* Fix compatability between extension and convert decorators

0.8 (2014-03-13)
````````````````
* Boolean flags create both '--opt' and '--no-opt' command line options
CHANGES
=======

* Switch to pbr for less boilerplate
* Add env markers to requirements.txt also
* Add a link to the YouTube video of Pycon-AU talk
* Minor documentation updates
* Ensure mock is installed when testing
* Add Github's gitignore for Python
* Fix typo
* Shorten README documentation

0.9
---

* Update CHANGELOG and version for 0.9 release
* Update Trove specifiers to mark beta release
* Update Trove specifiers to include Python 3.4
* Restore table of contents on main page
* Mock out external packages from Sphinx builds
* Make logging tests compatible with Python 3.4
* Run continuous integrations tests on Python 3.4
* Make convert compatible with extensions
* Major update to begins documentation
* Always show table of contents in sidebar
* Update flask quickstart to use auto_convert
* Additional example applications
* Update date in license file
* Partially complete Sphinx documentation
* Remove development roadmap

0.8
---

* Update CHANGELOG and version for 0.8 release
* Document new command line flags
* Prevent begins setting unprotected properties
* Remove deprecation warnings from unittests
* Correct behaviour of --no-flag command line flags
* Restructure CHANGELOG list for next release
* Use both '--opt' and '--no-opt' command line opts
* Replace '_' with '-' in command line option flags
* Add last_return and return_values to begin.context
* Module for creating custom help formatters
* Run main function once before all subcommands
* Use custom help formatter with subcommands
* Build and upload Python wheel packages to PyPI
* Resolution to issue #23
* Correctly create required, positional arguments
* Enable creating sub-commands with a specified name
* Custom help formatters for control command line help output
* Create positional command line arguments for required parameters
* Published Python wheel packages to PyPI to improve install times
* Deprecate context.return_value for context.last_return and
context.return_values

0.7.1 (2013-10-03)
``````````````````
* Fix incompatability between automatic type conversion and command line flags

0.7 (2013-10-01)
````````````````
* New utility functions tofile and tolist
* Fix bug prevent help output with main function that takes on arguments
* Multiple subcommands support can be enabled with cmd_delim
* Context object available to main and subcommand functions for storing state
* Optional automatic type conversion for begin.convert and begin.start
* Command line flags for options with boolean default values

0.6 (2013-08-27)
````````````````
* Allow listing of optins in alphabetical order
* Allow suppression of short options

0.5 (2013-08-01)
````````````````
* Add support for sub-commands, sub-command groups and entry points

0.4 (2013-07-20)
````````````````
* Add function decorators to extend command line options to:
* Configure the logging module
* Configrue the tracebacks module
* Support configuration files to set defaults for command line options

0.3 (2013-07-10)
````````````````
* Depend on external funcsigs package for Python earlier than 3.3
* Depend on external argparse package for Python 2.6
* Use argparse instead over optparse internally for command line processing

0.2 (2013-07-04)
````````````````
* Fix missing begin.funcsigs package in source distribution

0.1 (2013-03-24)
````````````````
* First version released
* begin.start() decorator
* begin.convert() decorator

0.7.1
-----

* Add Twine to list of requirements
* Fix incompatiblity with type conversion and flags

0.7
---

* Version bump to 0.7
* Update changelog for 0.7 release
* Document flags and automatic type conversion
* Arguments with boolean defaults treated as flags
* Support automatic type conversion for files
* Automatic type conversion with begin.start
* Add missing unittest for long conversion
* Fix type in doctest from README
* Add automatic type conversion to begin.convert()
* Ensure tobool returns a boolean object
* Create context location for passing program state
* Correct spelling errors
* Support multiple subcommands on command line
* Ensure help output with empty main function
* Add tofile and tolist utility functions

0.6
---

* Version bump to 0.6
* Update changelog for 0.6 release
* Update package short description
* Stop backtrace when a KeyboardInterrupt raised
* Don't use magic value names for program name
* Enable listing options in alphabetical order
* Suppress exceptions on exit from logging module
* Correctly test log levels passed to the log API
* Use public function to get logging level name
* Pass log level numbers, not names, to logging
* Suppress logging exceptions on Python 2.6
* Include subcommand docstring in help output
* Allow suppressing of short options

0.5
---

* Version bump to 0.5
* Update changelog for 0.5 release
* Conflict resolution for subcommand options
* Add named groups and plugins for subcommands
* subcommand decorator accepts and entry_point group
* Subcommand collector can load from entry_points
* Make the subcommand collector a dict subclass
* Skip subcommands examples from doctests
* Add support for subcommands
* Factor out argument parser populating

0.4
---

* Version bump to 0.4
* Update changelog for 0.4 release
* Update installation instructions
* Fix missing keyword argument for config section
* Add config file support for command extensions
* Set option's default value from config file
* Create manager for command line defaults
* Document use of entry points with begins
* Add start method to decorated main functions
* Factor out base class for decorator classes
* Stop unwrapping on presence of __signature__
* Add missing __all__ variable
* Add command line extension for logging module
* Add command line extension for cgitb module
* Rename Bottle and Flask example applications
* Add base class for command line extensions
* Add .PHONY target to Makefile
* Fix typo in package README file

0.3
---

* Update version and CHANGELOG for 0.3 release
* Make environment variable processing optional
* Fix annotations on variable positional args
* Fix applying command line to keyword only args
* Use argparse internally for command line parsing
* Add basic usage examples to examples collection
* Update changelog for 0.3 release
* Add PyPI version badge to README
* Remove vendored funcsigs package

0.2
---

* Version increment for 0.2 release
* Add roadmap for beta release of docs
* Prefer __wrapped__ attribute convention
* Add missing funcsigs package to source release

0.1
---

* Add register target to Makefile
* Update CHANGELOG for version 0.1 release
* Add Flask and Bottle based examples
* Make metavar in usage help be env variable name
* Add begin.convert() decorator
* Add module for utility functions
* Support prefixes for environment variables
* Update web links in README
* Reposition build and test coverage badges
* Expand README documentation
* Update function doc strings
* Show default values in command line help
* Override option values from system environment
* Alter usage string if variable arguments used
* Support required command line options
* Avoid passing positional args to function twice
* Remove use of sys.atexit to call main funciton
* Add missing unit tests for vendored funcsigs
* Ensure main decorator returns original function
* Add coverage report badge to README
* Enable coveralls code coverage reports
* Tweak coverage reports
* Vendor latest funcsigs
* Don't use PyPI mirrors when installing packages
* Add Python 3.3 as a supported version
* Discontinue use of distribute_setup.py
* Raise exception if decorating non-callable
* Mock atexit.register during doctests
* Change tag line for package
* Add missing documenation to README
* Add cmdline parsing to begin.start decorator
* Add utility to call func using command line opts
* Add tests for version number and valid README
* Raise exception with variable keyword arguments
* Add command line generating utilities
* Update copyright date in package documentation
* Enable continuous integration testing of PyPy
* Skip tests for __call__ method of builtins on PyPy
* Special case the type object fail
* Update funcsigs module definition
* Catch exceptiont over testing for MappingProxyType
* Don't test against PyPy
* Fix typo in Pip command line
* Configure continuous integration with Travis-CI
* Make compatible with Python2.6 syntax
* Add OrderedDict backport for Python 2.6
* Add basic function signature tests
* Rename tests for funcsigs to test for inspect
* Skip assignment of function to __wrapped__ attr
* Make callable classes compatible with Python2
* Skip immutability test for SignatureObject on Py2
* Define __hash__ on expected unhashable classes
* Ensure all classes are new style classes
* Use OrderedDict over MappingProxyType in Python2
* Define assertRaisesRegex is missong on TestCase
* Test for valid identifiers names with regex
* Access __annotations__ with getattr function
* Access __annotations__ with getattr function
* Access co_kwonlyargcount with getattr function
* Syntax port to add Python2 support
* Syntax port to add Python2 support
* Add PEP362 functions from Python3 inspect module
* Expand begin package __init__ module
* Add new unittest tests
* Add new unittest tests
* Add mock package as a requirement for testing
* Improve compatability with Py2 and Py3
* Use unittest2 with Python2 interpreters
* Add new unittest tests
* Update README documentation and docstrings
* Remove unused import
* Remove command line parsing functionality
* Rename begin.execute() method to begin.start()
* Update package metadata
* Add Makefile with common command targets
* Create CHANGELOG
* Create template Sphinx documentation
* Create Pip requirements file
* Create MANIFEST file
* Add LICENSE file
* Rename Python package to begin
* Update distribute setup script to 0.6.34
* Add main.parse_cmdline functionality
* Refactor main.execute unit tests
* Refactor main.execute into separate module
* Fix PEP8 errors
* Update package metadata
* Initial commit with main.execute() function
5 changes: 0 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/usr/bin/env python
from setuptools import setup
import re
import sys

PYTHON3K = sys.version_info[0] > 2

setup(
setup_requires=['pbr'],
pbr=True,
tests_require=['mock'] + ([] if PYTHON3K else ['unittest2']),
test_suite="tests" if PYTHON3K else "unittest2.collector"
)
36 changes: 36 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[tox]
minversion = 1.6
skipsdist = True
envlist = py32,py33,py34,py26,py27,pypy,pep8,docs

[testenv]
usedevelop = True
install_command = pip install testrepository {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
commands = python setup.py testr --testr-args='{posargs}'

[tox:jenkins]
sitepackages = True
downloadcache = ~/cache/pip

[testenv:pep8]
commands = flake8 {posargs}

[testenv:docs]
commands = python setup.py build_sphinx

[testenv:cover]
setenv = VIRTUAL_ENV={envdir}
commands =
python setup.py testr --coverage

[testenv:venv]
commands = {posargs}

[flake8]
# H405 multi line docstring summary not separated with an empty line
# H904 "Wrap lines in parentheses and not a backslash for line continuation
# Removed in current hacking (https://review.openstack.org/#/c/101701/).
ignore = H405,H803,H904
exclude = .venv,.tox,dist,doc,*.egg,build
show-source = true

0 comments on commit c2e2e84

Please sign in to comment.