Merge branch 'IvanMalison-fix_get_cache_key_and_make_package' into develop

This commit is contained in:
hugovk 2015-01-08 10:45:03 +02:00
commit 882e749331
10 changed files with 78 additions and 102 deletions

1
.build Normal file
View file

@ -0,0 +1 @@
0

View file

@ -1,43 +1,32 @@
language: python language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "pypy"
- "pypy3"
sudo: false
install:
- travis_retry pip install -r test_requirements.txt
- travis_retry pip install coveralls
script: coverage run --source=pylast ./test_pylast.py
after_success:
- coveralls
- travis_retry pip install scrutinizer-ocular
- ocular
after_script:
- coverage report
- ./check.sh
- pip install clonedigger
- clonedigger pylast.py
- grep "Clones detected" output.html
- grep "lines are duplicates" output.html
env: env:
global: global:
- secure: ivg6II471E9HV8xyqnawLIuP/sZ0J63Y+BC0BQcRVKtLn/K3zmD1ozM3TFL9S549Nxd0FqDKHXJvXsgaTGIDpK8sxE2AMKV5IojyM0iAVuN7YjPK9vwSlRw1u0EysPMFqxOZVQnoDyHrSGIUrP/VMdnhBu6dbUX0FyEkvZshXhY= - secure: ivg6II471E9HV8xyqnawLIuP/sZ0J63Y+BC0BQcRVKtLn/K3zmD1ozM3TFL9S549Nxd0FqDKHXJvXsgaTGIDpK8sxE2AMKV5IojyM0iAVuN7YjPK9vwSlRw1u0EysPMFqxOZVQnoDyHrSGIUrP/VMdnhBu6dbUX0FyEkvZshXhY=
- secure: gDWNEYA1EUv4G230/KzcTgcmEST0nf2FeW/z/prsoQBu+TWw1rKKSJAJeMLvuI1z4aYqqNYdmqjWyNhhVK3p5wmFP2lxbhaBT1jDsxxFpePc0nUkdAQOOD0yBpbBGkqkjjxU34HjTX2NFNEbcM3izVVE9oQmS5r4oFFNJgdL91c= - secure: gDWNEYA1EUv4G230/KzcTgcmEST0nf2FeW/z/prsoQBu+TWw1rKKSJAJeMLvuI1z4aYqqNYdmqjWyNhhVK3p5wmFP2lxbhaBT1jDsxxFpePc0nUkdAQOOD0yBpbBGkqkjjxU34HjTX2NFNEbcM3izVVE9o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ot9tazTHs=
- secure: CQYL7MH6tSVrCcluIfWfDSTo4E/p+9pF0eI7Vtf0oaZBzyulODHK8h/mzJp4HwezyfOu0RCedq6sloGQr1/29CvWWESaYyoGoGz9Mz2ZS+MpIcjGISfZa+x4vSp6QPFvd4i/1Z/1j2gJVVyswkrIVUwZIDJtfAKzZI5iHx2gH8Y=
- secure: SsKJoJwtDVWrL5xxl9C/gTRy6FhfRQQNNAFOogl9mTs/WeI2t9QTYoKsxLPXOdoRdu4MvT3h/B2sjwggt7zP81fBVxQRTkg4nq0zSHlj0NqclbFa6I5lUYdGwH9gPk/HWJJwXhKRDsqn/iRw2v+qBDs/j3kIgPQ0yjM58LEPXic=
matrix:
- TOXENV=py27
- TOXENV=py33
- TOXENV=py34
- TOXENV=pypy
- TOXENV=pypy3
- TOXENV=lint
sudo: false
install:
- travis_retry pip install tox
- travis_retry pip install coveralls
script: tox
after_success:
- travis_retry pip install coveralls && coveralls
- travis_retry pip install scrutinizer-ocular && ocular
matrix: matrix:
allow_failures: allow_failures:
- python: "3.4" - python: '3.4'
- python: "pypy" - python: pypy
- python: "pypy3" - python: pypy3
fast_finish: true fast_finish: true

View file

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

View file

@ -1070,7 +1070,7 @@ class _Request(object):
for key in keys: for key in keys:
if key != "api_sig" and key != "api_key" and key != "sk": if key != "api_sig" and key != "api_key" and key != "sk":
cache_key += key + _string(self.params[key]) cache_key += key + self.params[key]
return hashlib.sha1(cache_key.encode("utf-8")).hexdigest() return hashlib.sha1(cache_key.encode("utf-8")).hexdigest()

View file

@ -1,12 +1,14 @@
#!/usr/bin/env python #!/usr/bin/env python
import os
from distutils.core import setup from setuptools import setup, find_packages
setup( setup(
name="pylast", name="pylast",
version="1.0.0", version="1.0.0",
author="Amr Hassan <amr.hassan@gmail.com>", author="Amr Hassan <amr.hassan@gmail.com>",
tests_require=['mock', 'pytest', 'coverage', 'pep8', 'pyyaml', 'pyflakes'],
description=("A Python interface to Last.fm " description=("A Python interface to Last.fm "
"(and other API compatible social networks)"), "(and other API compatible social networks)"),
author_email="amr.hassan@gmail.com", author_email="amr.hassan@gmail.com",
@ -24,8 +26,8 @@ setup(
"Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.4",
], ],
keywords=["Last.fm", "music", "scrobble", "scrobbling"], keywords=["Last.fm", "music", "scrobble", "scrobbling"],
py_modules=("pylast",), packages=find_packages(exclude=('tests*')),
license="Apache2" license="Apache2"
) )
# End of file # End of file

View file

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

0
tests/__init__.py Normal file
View file

18
tests/request_test.py Normal file
View file

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
import mock
import pytest
import pylast
def mock_network():
return mock.Mock(
_get_ws_auth=mock.Mock(return_value=("", "", ""))
)
@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})
request._get_cache_key()

View file

@ -2,7 +2,6 @@
""" """
Integration (not unit) tests for pylast.py Integration (not unit) tests for pylast.py
""" """
import argparse
import os import os
from random import choice from random import choice
import sys import sys
@ -1911,52 +1910,4 @@ class TestPyLast(unittest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser( unittest.main(failfast=True)
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

30
tox.ini Normal file
View file

@ -0,0 +1,30 @@
[tox]
envlist = py34, py27, pypy, pypy3
recreate = False
[testenv]
downloadcache = {homedir}/.pipcache
deps =
pyyaml
pytest
mock
pytest-cov
commands = py.test -v --cov pylast --cov-report term-missing {posargs}
[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"