mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 14:14:19 +00:00
Merge pull request #656 from JonnyWong16/feature/object_parent
Fix checking object parent when the weakref is dead
This commit is contained in:
commit
f66624f2bd
2 changed files with 12 additions and 2 deletions
|
@ -124,9 +124,9 @@ class PlexObject(object):
|
|||
See all possible `**kwargs*` in :func:`~plexapi.base.PlexObject.fetchItem`.
|
||||
"""
|
||||
obj = self
|
||||
while obj._parent is not None:
|
||||
while obj and obj._parent is not None:
|
||||
obj = obj._parent()
|
||||
if obj._checkAttrs(obj._data, **kwargs):
|
||||
if obj and obj._checkAttrs(obj._data, **kwargs):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
|
@ -799,6 +799,16 @@ def test_video_Episode_hidden_season(episode):
|
|||
show.defaultAdvanced()
|
||||
|
||||
|
||||
def test_video_Episode_parent_weakref(show):
|
||||
season = show.season(season=1)
|
||||
episode = season.episode(episode=1)
|
||||
assert episode._parent is not None
|
||||
assert episode._parent() == season
|
||||
episode = show.season(season=1).episode(episode=1)
|
||||
assert episode._parent is not None
|
||||
assert episode._parent() is None
|
||||
|
||||
|
||||
# Analyze seems to fail intermittently
|
||||
@pytest.mark.xfail
|
||||
def test_video_Episode_analyze(tvshows):
|
||||
|
|
Loading…
Reference in a new issue