From ca66e74099104183956b61944fc76a2746ebf40f Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 7 Jan 2015 17:57:04 -0800 Subject: [PATCH] tox/travis stuff. making testing more uniform. --- .travis.yml | 30 ++++++++++--------------- check.sh | 11 ---------- test_requirements.txt | 4 ---- tests/request_test.py | 3 ++- tests/test_pylast.py | 51 ------------------------------------------- tox.ini | 25 ++++++++++++++++++--- 6 files changed, 35 insertions(+), 89 deletions(-) delete mode 100755 check.sh delete mode 100644 test_requirements.txt diff --git a/.travis.yml b/.travis.yml index 9efd262..f96caf8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/check.sh b/check.sh deleted file mode 100755 index 2aca7ef..0000000 --- a/check.sh +++ /dev/null @@ -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 diff --git a/test_requirements.txt b/test_requirements.txt deleted file mode 100644 index d304a29..0000000 --- a/test_requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -coverage -pep8 -pyyaml -pyflakes diff --git a/tests/request_test.py b/tests/request_test.py index fb18091..bb72f62 100644 --- a/tests/request_test.py +++ b/tests/request_test.py @@ -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}) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index bc5dcb8..8f2fe90 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -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 diff --git a/tox.ini b/tox.ini index 8565df0..03fee87 100644 --- a/tox.ini +++ b/tox.ini @@ -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} \ No newline at end of file + 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" \ No newline at end of file