Skip tests which fail due to the (still) broken Last.fm API

This commit is contained in:
hugovk 2016-01-07 18:09:28 +02:00
parent 6ecba676bc
commit 950c2e78ca
2 changed files with 31 additions and 18 deletions

33
.gitignore vendored
View file

@ -1,6 +1,7 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
@ -8,11 +9,12 @@ __pycache__/
# Distribution / packaging
.Python
env/
bin/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
@ -22,6 +24,12 @@ var/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
@ -30,33 +38,22 @@ pip-delete-this-directory.txt
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
output.html
output.xml
*,cover
.hypothesis/
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# Rope
.ropeproject
*.pot
# Django stuff:
*.log
*.pot
# Sphinx documentation
docs/_build/
# Test files
test_pylast.yaml
lastfm.txt.pkl
secrets.sh
.dir-locals.el
# PyBuilder
target/

View file

@ -30,6 +30,21 @@ def load_secrets():
return doc
def handle_lastfm_exceptions(f):
def wrapper(*args, **kw):
try:
return f(*args, **kw)
except pylast.WSError as e:
if (str(e) == "Invalid Method - "
"No method with that name in this package"):
msg = "Ignore broken Last.fm API: " + str(e)
print(msg)
pytest.skip(msg)
else:
raise(e)
return wrapper
@flaky(max_runs=5, min_passes=1)
class TestPyLast(unittest.TestCase):
@ -87,6 +102,7 @@ class TestPyLast(unittest.TestCase):
last_scrobble = lastfm_user.get_recent_tracks(limit=2)[0]
self.assertNotEqual(str(last_scrobble.timestamp), str(timestamp))
@handle_lastfm_exceptions
def test_add_album(self):
# Arrange
library = pylast.Library(user=self.username, network=self.network)