Merge pull request #326 from pylast/fix-if-bio-is-empty
Fix artist.get_bio_content() to return None if bio is empty
This commit is contained in:
commit
898a8b5756
|
@ -1,6 +1,6 @@
|
|||
repos:
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.1.0
|
||||
rev: v2.4.1
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: ["--py3-plus"]
|
||||
|
@ -15,13 +15,13 @@ repos:
|
|||
types: []
|
||||
|
||||
- repo: https://gitlab.com/pycqa/flake8
|
||||
rev: 3.7.9
|
||||
rev: 3.8.0a2
|
||||
hooks:
|
||||
- id: flake8
|
||||
additional_dependencies: [flake8-2020, flake8-implicit-str-concat]
|
||||
|
||||
- repo: https://github.com/asottile/seed-isort-config
|
||||
rev: v2.1.0
|
||||
rev: v2.1.1
|
||||
hooks:
|
||||
- id: seed-isort-config
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
[Travis CI](https://travis-ci.org/pylast/pylast) should be running cleanly for
|
||||
all merges to master.
|
||||
|
||||
* [ ] Edit release draft, adjust text if needed: https://github.com/pylast/pylast/releases
|
||||
* [ ] Edit release draft, adjust text if needed:
|
||||
https://github.com/pylast/pylast/releases
|
||||
|
||||
* [ ] Check next tag is correct, amend if needed
|
||||
|
||||
|
|
|
@ -1142,7 +1142,12 @@ class _BaseObject:
|
|||
def _extract_cdata_from_request(self, method_name, tag_name, params):
|
||||
doc = self._request(method_name, True, params)
|
||||
|
||||
return doc.getElementsByTagName(tag_name)[0].firstChild.wholeText.strip()
|
||||
first_child = doc.getElementsByTagName(tag_name)[0].firstChild
|
||||
|
||||
if first_child is None:
|
||||
return None
|
||||
|
||||
return first_child.wholeText.strip()
|
||||
|
||||
def _get_things(self, method, thing, thing_type, params=None, cacheable=True):
|
||||
"""Returns a list of the most played thing_types by this thing."""
|
||||
|
|
|
@ -52,6 +52,17 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
self.assertIsNotNone(bio)
|
||||
self.assertGreaterEqual(len(bio), 1)
|
||||
|
||||
def test_bio_content_none(self):
|
||||
# Arrange
|
||||
# An artist with no biography, with "<content/>" in the API XML
|
||||
artist = pylast.Artist("Mr Sizef + Unquote", self.network)
|
||||
|
||||
# Act
|
||||
bio = artist.get_bio_content()
|
||||
|
||||
# Assert
|
||||
self.assertIsNone(bio)
|
||||
|
||||
def test_bio_summary(self):
|
||||
# Arrange
|
||||
artist = pylast.Artist("Test Artist", self.network)
|
||||
|
|
Loading…
Reference in a new issue