tox/travis stuff. making testing more uniform.

This commit is contained in:
Ivan Malison 2015-01-07 17:57:04 -08:00
parent c2b03afe55
commit ca66e74099
6 changed files with 35 additions and 89 deletions

View file

@ -1,32 +1,24 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "pypy"
- "pypy3"
env:
- TOXENV=py27
- TOXENV=py33
- TOXENV=py34
- TOXENV=pypy
- TOXENV=pypy3
- TOXENV=lint
sudo: false
install:
- travis_retry pip install -r test_requirements.txt
- travis_retry pip install coveralls
script: coverage run --source=pylast ./tests/test_pylast.py
script: tox
after_success:
- coveralls
- travis_retry pip install scrutinizer-ocular
- ocular
after_script:
- coverage report
- ./check.sh
- pip install clonedigger
- clonedigger pylast
- grep "Clones detected" output.html
- grep "lines are duplicates" output.html
- "if [ $TOXENV == 'py27' ]; then pip install coveralls; coveralls; fi"
- "if [ $TOXENV == 'py27' ]; then travis_retry pip install scrutinizer-ocular; ocular; fi"
- "if [ $TOXENV == 'py27' ]; then travis_retry pip install scrutinizer-ocular; ocular; fi"
env:
global:

View file

@ -1,11 +0,0 @@
pyflakes pylast
echo ---
pyflakes tests
echo ---
pep8 pylast
echo ---
pep8 tests
# echo ---
# clonedigger pylast.py
# grep "Clones detected" output.html
# grep "lines are duplicates" output.html

View file

@ -1,4 +0,0 @@
coverage
pep8
pyyaml
pyflakes

View file

@ -10,7 +10,8 @@ def mock_network():
_get_ws_auth=mock.Mock(return_value=("", "", ""))
)
@pytest.mark.parametrize('unicode_artist', [u'\xe9lafdasfdsafdsa', u'éééééééé'])
@pytest.mark.parametrize('unicode_artist', [u'\xe9lafdasfdsafdsa', u'ééééééé])
def test_get_cache_key(unicode_artist):
request = pylast._Request(mock_network(), 'some_method',
params={'artist': unicode_artist})

View file

@ -2,7 +2,6 @@
"""
Integration (not unit) tests for pylast.py
"""
import argparse
import os
from random import choice
import sys
@ -1909,54 +1908,4 @@ class TestPyLast(unittest.TestCase):
self.assertEqual(str(tracks[0].track.artist), "Johnny Cash")
self.assertEqual(str(tracks[0].track.title), "Ring of Fire")
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Integration (not unit) tests for pylast.py",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'-1', '--single',
help="Run a single test")
parser.add_argument(
'-r', '--repeat',
help="Repeat a single test (100 times) until failure")
parser.add_argument(
'-m', '--matching',
help="Run tests with this in the name")
args = parser.parse_args()
if args.single:
suite = unittest.TestSuite()
suite.addTest(TestPyLast(args.single))
unittest.TextTestRunner().run(suite)
elif args.repeat:
suite = unittest.TestSuite()
suite.addTest(TestPyLast(args.repeat))
for i in range(100):
print("Attempt " + str(i+1))
result = unittest.TextTestRunner().run(suite)
problems = len(result.errors) + len(result.failures)
if problems:
break
elif args.matching:
suite = unittest.TestSuite()
import inspect
methods = inspect.getmembers(TestPyLast, predicate=inspect.ismethod)
tests = []
for method, _ in methods:
if method.startswith("test_") and args.matching in method:
print(method)
suite.addTest(TestPyLast(method))
unittest.TextTestRunner().run(suite)
else:
unittest.main(failfast=True)
# End of file

25
tox.ini
View file

@ -1,11 +1,30 @@
[tox]
envlist = py34, py27
envlist = py34, py27, pypy, pypy3
recreate = False
[testenv]
downloadcache = {homedir}/.pipcache
changedir = tests
deps =
pyyaml
pytest
mock
commands = py.test {posargs}
pytest-cov
commands = py.test --doctest-modules -v --cov pylast --cov-report term-missing
[testenv:venv]
deps = ipdb
commands = {posargs}
[testenv:lint]
deps =
coverage
pep8
pyyaml
pyflakes
clonedigger
commands =
pyflakes pylast
pyflakes tests
pep8 pylast
pep8 tests
clonedigger pylast -o /dev/stdout | grep -E "Clones detected\|lines are duplicates"