Update tests and testing requirements
- pep257 with our patches (>=0.3.2) - flake8_docstring with our patch (>=0.2.0) - python-whois with python 3 patches - don't need Babel or WebOb yet; remove - sort alphabetically where order is not important - indicate python 3/3.3 compatibility; classifiers - document running coverage report - add coverage and virtual env paths to .gitignore - fix coverage filtering to not include tests - tweak pylintrc Change-Id: I0e840a424bebd35d349a21ab769f47da7b34a02d
This commit is contained in:
parent
b7c0e0abae
commit
f6080c5271
@ -1,7 +1,7 @@
|
|||||||
[run]
|
[run]
|
||||||
branch = True
|
branch = True
|
||||||
source = satori
|
source = satori
|
||||||
omit = satori/openstack/*
|
omit = satori/tests/*
|
||||||
|
|
||||||
[report]
|
[report]
|
||||||
ignore-errors = True
|
ignore-errors = True
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -24,6 +24,7 @@ pip-log.txt
|
|||||||
|
|
||||||
# Unit test / coverage reports
|
# Unit test / coverage reports
|
||||||
.coverage
|
.coverage
|
||||||
|
.coverage.*
|
||||||
cover
|
cover
|
||||||
covhtml
|
covhtml
|
||||||
.tox
|
.tox
|
||||||
@ -46,11 +47,11 @@ nosetests.xml
|
|||||||
*.swo
|
*.swo
|
||||||
*.swp
|
*.swp
|
||||||
*~
|
*~
|
||||||
.coverage
|
|
||||||
.satori-venv
|
.satori-venv
|
||||||
.testrepository
|
.testrepository
|
||||||
.tox
|
.tox
|
||||||
.venv
|
.venv
|
||||||
|
venv
|
||||||
AUTHORS
|
AUTHORS
|
||||||
build
|
build
|
||||||
ChangeLog
|
ChangeLog
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
|
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
|
||||||
${PYTHON:-python} -m subunit.run discover -t ./ ./satori/tests $LISTOPT $IDOPTION
|
${PYTHON:-python} -m subunit.run discover -t . ./satori/tests $LISTOPT $IDOPTION
|
||||||
|
|
||||||
test_id_option=--load-list $IDFILE
|
test_id_option=--load-list $IDFILE
|
||||||
test_list_option=--list
|
test_list_option=--list
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
graft satori/formats
|
graft satori/formats
|
||||||
include setup.py
|
include setup.py
|
||||||
include setup.cfg
|
include setup.cfg
|
||||||
|
prune satori/tests
|
||||||
global-exclude *.pyc *.sdx *.log *.db *.swp
|
global-exclude *.pyc *.sdx *.log *.db *.swp
|
||||||
|
26
README.rst
26
README.rst
@ -108,7 +108,31 @@ uses the `install virtualenv`_ script to create the virtualenv::
|
|||||||
|
|
||||||
Unit tests can be ran simply by running::
|
Unit tests can be ran simply by running::
|
||||||
|
|
||||||
$ run_tests.sh
|
$ tox
|
||||||
|
|
||||||
|
# or, just style checks
|
||||||
|
$ tox -e pep8
|
||||||
|
|
||||||
|
# or, just python 2.7 checks
|
||||||
|
$ tox -e py27
|
||||||
|
|
||||||
|
|
||||||
|
Running a test coverage report:
|
||||||
|
|
||||||
|
# cleanup previous runs
|
||||||
|
$ rm -rf cover && rm -rf covhtml && rm .coverage
|
||||||
|
|
||||||
|
# Run tests and generate the report
|
||||||
|
$ tox -ecover && coverage html -d covhtml -i
|
||||||
|
|
||||||
|
# open it in a broweser
|
||||||
|
$ open covhtml/index.html
|
||||||
|
|
||||||
|
Checking test coverage::
|
||||||
|
|
||||||
|
$ tox -ecover
|
||||||
|
$ coverage html -d covhtml -i
|
||||||
|
$ open covhtml/index.html # opens the report in a browser
|
||||||
|
|
||||||
|
|
||||||
Links
|
Links
|
||||||
|
11
pylintrc
Normal file
11
pylintrc
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[Messages Control]
|
||||||
|
# W0511: TODOs in code comments are fine.
|
||||||
|
# W0142: *args and **kwargs are fine.
|
||||||
|
disable-msg=W0511,W0142
|
||||||
|
|
||||||
|
# Don't require docstrings on tests.
|
||||||
|
no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$
|
||||||
|
|
||||||
|
[Design]
|
||||||
|
min-public-methods=0
|
||||||
|
max-args=6
|
@ -5,6 +5,6 @@ https://github.com/paramiko/paramiko/archive/python3.zip#egg=paramiko-1.13.0
|
|||||||
pbr>=0.5.21,<1.0
|
pbr>=0.5.21,<1.0
|
||||||
python-novaclient==2.15.0
|
python-novaclient==2.15.0
|
||||||
# pythonwhois with python 3.3 readiness patch
|
# pythonwhois with python 3.3 readiness patch
|
||||||
-e git://github.com/joepie91/python-whois.git@655d1ca37497f0f6407c6bdbe0d2bbd0caac8544#egg=pythonwhois
|
-e git://github.com/ziadsawalha/python-whois.git@17aa17c1c71805df1cb7fa053fe90b6dc9ba6d4b#egg=pythonwhois
|
||||||
six==1.5.2
|
six==1.5.2
|
||||||
tldextract==1.3.1
|
tldextract==1.3.1
|
||||||
|
@ -9,15 +9,14 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
|
||||||
|
|
||||||
"""Satori main module."""
|
"""Satori main module."""
|
||||||
|
|
||||||
__all__ = ['__version__']
|
__all__ = ('__version__')
|
||||||
|
|
||||||
import pbr.version
|
import pbr.version
|
||||||
|
|
||||||
from satori.shell import main
|
from satori import shell
|
||||||
|
|
||||||
|
|
||||||
version_info = pbr.version.VersionInfo('satori')
|
version_info = pbr.version.VersionInfo('satori')
|
||||||
@ -32,5 +31,5 @@ def discover(address=None):
|
|||||||
|
|
||||||
TODO(zns): make it real
|
TODO(zns): make it real
|
||||||
"""
|
"""
|
||||||
main(argv=[address])
|
shell.main(argv=[address])
|
||||||
return {'address': address, 'other info': '...'}
|
return {'address': address, 'other info': '...'}
|
||||||
|
@ -31,6 +31,11 @@ class DebugFormatter(logging.Formatter):
|
|||||||
|
|
||||||
Outputs any 'data' values passed in the 'extra' parameter if provided.
|
Outputs any 'data' values passed in the 'extra' parameter if provided.
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
LOG.debug("My message", extra={'data': locals()})
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
@ -46,7 +51,8 @@ def init_logging(config, default_config=None):
|
|||||||
|
|
||||||
Turn on console logging if no logging files found
|
Turn on console logging if no logging files found
|
||||||
|
|
||||||
:param config: object with configuration namespace (argparse parser)
|
:param config: object with configuration namespace (ex. argparse parser)
|
||||||
|
:keyword default_config: path to a python logging configuration file
|
||||||
"""
|
"""
|
||||||
if config.logconfig and os.path.isfile(config.logconfig):
|
if config.logconfig and os.path.isfile(config.logconfig):
|
||||||
logging.config.fileConfig(config.logconfig,
|
logging.config.fileConfig(config.logconfig,
|
||||||
@ -74,6 +80,8 @@ def log_level(config):
|
|||||||
--verbose: turn up logging output (logging.DEBUG)
|
--verbose: turn up logging output (logging.DEBUG)
|
||||||
--quiet: turn down logging output (logging.WARNING)
|
--quiet: turn down logging output (logging.WARNING)
|
||||||
default is logging.INFO
|
default is logging.INFO
|
||||||
|
|
||||||
|
:param config: object with configuration namespace (ex. argparse parser)
|
||||||
"""
|
"""
|
||||||
if config.debug is True:
|
if config.debug is True:
|
||||||
return logging.DEBUG
|
return logging.DEBUG
|
||||||
@ -95,6 +103,7 @@ def get_debug_formatter(config):
|
|||||||
--quiet: turn down logging output (logging.WARNING)
|
--quiet: turn down logging output (logging.WARNING)
|
||||||
default is logging.INFO
|
default is logging.INFO
|
||||||
|
|
||||||
|
:param config: object with configuration namespace (ex. argparse parser)
|
||||||
"""
|
"""
|
||||||
if config.debug is True:
|
if config.debug is True:
|
||||||
return DebugFormatter('%(pathname)s:%(lineno)d: %(levelname)-8s '
|
return DebugFormatter('%(pathname)s:%(lineno)d: %(levelname)-8s '
|
||||||
@ -109,7 +118,10 @@ def get_debug_formatter(config):
|
|||||||
|
|
||||||
|
|
||||||
def init_console_logging(config):
|
def init_console_logging(config):
|
||||||
"""Log to console."""
|
"""Enable logging to the console.
|
||||||
|
|
||||||
|
:param config: object with configuration namespace (ex. argparse parser)
|
||||||
|
"""
|
||||||
# define a Handler which writes messages to the sys.stderr
|
# define a Handler which writes messages to the sys.stderr
|
||||||
console = find_console_handler(logging.getLogger())
|
console = find_console_handler(logging.getLogger())
|
||||||
if not console:
|
if not console:
|
||||||
|
@ -18,7 +18,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import jinja2
|
import jinja2
|
||||||
from jinja2.sandbox import ImmutableSandboxedEnvironment
|
from jinja2 import sandbox
|
||||||
import six
|
import six
|
||||||
|
|
||||||
CODE_CACHE = {}
|
CODE_CACHE = {}
|
||||||
@ -79,8 +79,9 @@ def preserve_linefeeds(value):
|
|||||||
def get_jinja_environment(template, extra_globals=None):
|
def get_jinja_environment(template, extra_globals=None):
|
||||||
"""Return a sandboxed jinja environment."""
|
"""Return a sandboxed jinja environment."""
|
||||||
template_map = {'template': template}
|
template_map = {'template': template}
|
||||||
env = ImmutableSandboxedEnvironment(loader=jinja2.DictLoader(template_map),
|
env = sandbox.ImmutableSandboxedEnvironment(
|
||||||
bytecode_cache=CompilerCache())
|
loader=jinja2.DictLoader(template_map),
|
||||||
|
bytecode_cache=CompilerCache())
|
||||||
env.filters['prepend'] = do_prepend
|
env.filters['prepend'] = do_prepend
|
||||||
env.filters['preserve'] = preserve_linefeeds
|
env.filters['preserve'] = preserve_linefeeds
|
||||||
env.globals['json'] = json
|
env.globals['json'] = json
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
|
||||||
"""Discovery Module.
|
"""Discovery Module.
|
||||||
|
|
||||||
TODO(zns): testing, refactoring, etc... just using this to demonstrate
|
TODO(zns): testing, refactoring, etc... just using this to demonstrate
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
# pylint: disable=C0103,R0904
|
|
||||||
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
@ -76,6 +74,11 @@ class TestArgParsing(utils.TestCase):
|
|||||||
|
|
||||||
"""Test Argument Parsing."""
|
"""Test Argument Parsing."""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestArgParsing, self).setUp()
|
||||||
|
self.mock_os = shell.os
|
||||||
|
self.mock_os.environ = {}
|
||||||
|
|
||||||
def make_env(self, exclude=None, fake_env=FAKE_ENV):
|
def make_env(self, exclude=None, fake_env=FAKE_ENV):
|
||||||
"""Create a patched os.environ.
|
"""Create a patched os.environ.
|
||||||
|
|
||||||
@ -85,7 +88,7 @@ class TestArgParsing(utils.TestCase):
|
|||||||
env = dict((k, v) for k, v in fake_env.items() if k != exclude)
|
env = dict((k, v) for k, v in fake_env.items() if k != exclude)
|
||||||
self.useFixture(fixtures.MonkeyPatch('os.environ', env))
|
self.useFixture(fixtures.MonkeyPatch('os.environ', env))
|
||||||
|
|
||||||
def shell(self, argstr, exitcodes=(0,)):
|
def run_shell(self, argstr, exitcodes=(0,)):
|
||||||
"""Simulate a user shell.
|
"""Simulate a user shell.
|
||||||
|
|
||||||
Borrowed from python-novaclient/novaclient/tests/test_shell.py.
|
Borrowed from python-novaclient/novaclient/tests/test_shell.py.
|
||||||
@ -128,7 +131,7 @@ class TestArgParsing(utils.TestCase):
|
|||||||
fields_copy.append('domain.com')
|
fields_copy.append('domain.com')
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
errors.SatoriShellException,
|
errors.SatoriShellException,
|
||||||
self.shell,
|
self.run_shell,
|
||||||
' '.join(fields_copy),
|
' '.join(fields_copy),
|
||||||
exitcodes=[0, 2]
|
exitcodes=[0, 2]
|
||||||
)
|
)
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import sys
|
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,10 @@ classifier =
|
|||||||
Programming Language :: Python :: 2.7
|
Programming Language :: Python :: 2.7
|
||||||
Programming Language :: Python :: 2.6
|
Programming Language :: Python :: 2.6
|
||||||
Programming Language :: Python :: 3
|
Programming Language :: Python :: 3
|
||||||
|
Programming Language :: Python :: 3.3
|
||||||
|
Programming Language :: Python :: Implementation
|
||||||
|
Programming Language :: Python :: Implementation :: CPython
|
||||||
|
Programming Language :: Python :: Implementation :: PyPy
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
packages =
|
packages =
|
||||||
|
@ -1,29 +1,17 @@
|
|||||||
# pep8 with support for empty files through flake8
|
# pep8 with support for empty files through flake8
|
||||||
-e git://github.com/ziadsawalha/pep8.git@19b64e1d6b52cb814e482188369f4db24e0e82c2#egg=pep8
|
-e git://github.com/ziadsawalha/pep8.git@19b64e1d6b52cb814e482188369f4db24e0e82c2#egg=pep8
|
||||||
|
|
||||||
# pep257 tool with fix for updated PEP-257 and __all__ as a list
|
|
||||||
# Two PR pending to upstream
|
|
||||||
-e git://github.com/ziadsawalha/pep257.git@7752b1c9977e5dfca70f7635e5bfc12442c540a6#egg=pep257
|
|
||||||
|
|
||||||
# PEP-257 plugin for flake8 with pending upstream change for support for latest pep257 tool
|
|
||||||
#
|
|
||||||
# Should be -e hg+https://bitbucket.org/ziadsawalha/flake8-docstrings@51864b0e7451bc0a43ab6fb0303e8a69961cb401#egg=flake8-docstring
|
|
||||||
# ... but mercurial (hg) doesn't seem to be installed on openstack infrastructure. So, using a github temporary fork
|
|
||||||
-e git://github.com/ziadsawalha/flake8_docstrings@v0.1.5#egg=flake8-docstring
|
|
||||||
|
|
||||||
# Newer hacking
|
# Newer hacking
|
||||||
# Includes two fixes for handling blank lines in files and for handling egg-linked libraries
|
# Includes two fixes for handling blank lines in files and for handling egg-linked libraries
|
||||||
-e git://github.com/ziadsawalha/hacking.git@76ff3d0c8b116df147b7e4ca00afda67a9537f2a#egg=hacking
|
-e git://github.com/ziadsawalha/hacking.git@76ff3d0c8b116df147b7e4ca00afda67a9537f2a#egg=hacking
|
||||||
|
|
||||||
|
|
||||||
coverage>=3.6
|
coverage>=3.6
|
||||||
discover
|
discover
|
||||||
|
flake8_docstrings>=0.2.0
|
||||||
fixtures>=0.3.14
|
fixtures>=0.3.14
|
||||||
|
freezegun
|
||||||
mock>=1.0
|
mock>=1.0
|
||||||
|
pep257>=0.3.2
|
||||||
sphinx>=1.1.2,<1.2
|
sphinx>=1.1.2,<1.2
|
||||||
testrepository>=0.0.17
|
testrepository>=0.0.17
|
||||||
testtools>=0.9.32
|
testtools>=0.9.32
|
||||||
WebOb>=1.2.3,<1.3
|
|
||||||
|
|
||||||
Babel>=1.3
|
|
||||||
freezegun
|
|
||||||
|
4
tox.ini
4
tox.ini
@ -18,12 +18,12 @@ commands = flake8
|
|||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
commands = python setup.py test --coverage --testr-args='{posargs}'
|
commands = python setup.py test --coverage --testr-args='^(?!.*test.*coverage).*$'
|
||||||
|
|
||||||
[tox:jenkins]
|
[tox:jenkins]
|
||||||
downloadcache = ~/cache/pip
|
downloadcache = ~/cache/pip
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore = E126,E202,W602,H302,H402
|
|
||||||
show-source = True
|
show-source = True
|
||||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,*satori/contrib*,*.ropeproject,*satori/tests*,setup.py
|
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,*satori/contrib*,*.ropeproject,*satori/tests*,setup.py
|
||||||
|
max-complexity = 12
|
||||||
|
Loading…
Reference in New Issue
Block a user