Assume no illegal XML and no more skipping broken Last.fm

This commit is contained in:
hugovk 2017-10-20 00:51:34 +03:00
parent b55b40c3fe
commit b559495366
4 changed files with 0 additions and 35 deletions

View file

@ -22,7 +22,6 @@
from xml.dom import minidom, Node
import collections
import re
import hashlib
import shelve
import six
@ -108,18 +107,6 @@ SCROBBLE_MODE_LOVED = "L"
SCROBBLE_MODE_BANNED = "B"
SCROBBLE_MODE_SKIPPED = "S"
# From http://boodebr.org/main/python/all-about-python-and-unicode#UNI_XML
RE_XML_ILLEGAL = (u'([\u0000-\u0008\u000b-\u000c\u000e-\u001f\ufffe-\uffff])' +
u'|' +
u'([%s-%s][^%s-%s])|([^%s-%s][%s-%s])|([%s-%s]$)|(^[%s-%s])'
%
(unichr(0xd800), unichr(0xdbff), unichr(0xdc00),
unichr(0xdfff), unichr(0xd800), unichr(0xdbff),
unichr(0xdc00), unichr(0xdfff), unichr(0xd800),
unichr(0xdbff), unichr(0xdc00), unichr(0xdfff)))
XML_ILLEGAL = re.compile(RE_XML_ILLEGAL)
# Python >3.4 and >2.7.9 has sane defaults
SSL_CONTEXT = ssl.create_default_context()
@ -862,8 +849,6 @@ class _Request(object):
except Exception as e:
raise MalformedResponseError(self.network, e)
response_text = XML_ILLEGAL.sub("?", response_text)
self._check_response_for_errors(response_text)
conn.close()
return response_text

View file

@ -52,11 +52,6 @@ class PyLastTestCase(unittest.TestCase):
api_key=API_KEY, api_secret=API_SECRET,
username=self.username, password_hash=password_hash)
def skip_if_lastfm_api_broken(self, value):
"""Skip things not yet restored in Last.fm's broken API"""
if value is None or len(value) == 0:
pytest.skip("Last.fm API is broken.")
def helper_is_thing_hashable(self, thing):
# Arrange
things = set()

View file

@ -47,20 +47,6 @@ class TestPyLastNetwork(PyLastTestCase):
self.assertEqual(str(current_track.title), "test title")
self.assertEqual(str(current_track.artist), "Test Artist")
def test_invalid_xml(self):
# Arrange
# Currently causes PCDATA invalid Char value 25
artist = "Blind Willie Johnson"
title = "It's nobody's fault but mine"
# Act
search = self.network.search_for_track(artist, title)
total = search.get_total_result_count()
# Assert
self.skip_if_lastfm_api_broken(total)
self.assertGreaterEqual(int(total), 0)
def test_enable_rate_limiting(self):
# Arrange
self.assertFalse(self.network.is_rate_limited())

View file

@ -218,7 +218,6 @@ class TestPyLastUser(PyLastTestCase):
tags = user.get_top_tags(limit=1)
# Assert
self.skip_if_lastfm_api_broken(tags)
self.helper_only_one_thing_in_top_list(tags, pylast.Tag)
def test_user_top_tracks(self):