Skip to content

Commit 1c47a8f

Browse files
authored
Fix tests (#1587)
* Change Pillow `Image.getdata()` to `Image.get_flattened_data()` Pillow DeprecationWarning: Image.Image.getdata is deprecated and will be removed in Pillow 14 (2027-10-15). Use get_flattened_data instead. * Mark Movie on-demand subtitle test as xfail * Fix JWT login test plex.tv/devices.xml no longer returns the device token Ref.: https://forums.plex.tv/t/information-related-to-security-vulnerabilities/935164/17
1 parent e7d33f2 commit 1c47a8f

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def detect_color_image(file, thumb_size=150, MSE_cutoff=22, adjust_color_bias=Tr
450450
if adjust_color_bias:
451451
bias = ImageStat.Stat(thumb).mean[:3]
452452
bias = [b - sum(bias) / 3 for b in bias]
453-
for pixel in thumb.getdata():
453+
for pixel in thumb.get_flattened_data():
454454
mu = sum(pixel) / 3
455455
sse += sum(
456456
(pixel[i] - mu - bias[i]) * (pixel[i] - mu - bias[i]) for i in [0, 1, 2]

tests/test_myplex.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import pytest
44
from plexapi.exceptions import BadRequest, NotFound, Unauthorized
5-
from plexapi.myplex import MyPlexAccount, MyPlexInvite, MyPlexJWTLogin
6-
from plexapi.utils import createMyPlexDevice
5+
from plexapi.myplex import MyPlexAccount, MyPlexInvite, MyPlexPinLogin, MyPlexJWTLogin
6+
from plexapi.utils import generateUUID
77

88
from . import conftest as utils
99
from .payloads import MYPLEX_INVITE
@@ -371,14 +371,19 @@ def test_myplex_ping(account):
371371

372372
def test_myplex_jwt_login(account, tmp_path, monkeypatch):
373373
# Create a new MyPlexDevice for JWT tests
374-
device = createMyPlexDevice(account=account)
374+
clientIdentifier = generateUUID()
375+
headers = {'X-Plex-Client-Identifier': clientIdentifier}
376+
pinlogin = MyPlexPinLogin(headers=headers)
377+
pinlogin.run()
378+
account.link(pinlogin.pin)
379+
pinlogin.waitForLogin()
375380

376381
privkey = tmp_path / 'private.key'
377382
pubkey = tmp_path / 'public.key'
378383

379384
jwtlogin = MyPlexJWTLogin(
380-
headers={'X-Plex-Client-Identifier': device.clientIdentifier},
381-
token=device.token,
385+
headers=headers,
386+
token=pinlogin.token,
382387
scopes=['username', 'email', 'friendly_name']
383388
)
384389
jwtlogin.generateKeypair(keyfiles=(privkey, pubkey), overwrite=True)
@@ -391,7 +396,7 @@ def test_myplex_jwt_login(account, tmp_path, monkeypatch):
391396
assert new_account.username == account.username
392397

393398
jwtlogin = MyPlexJWTLogin(
394-
headers={'X-Plex-Client-Identifier': device.clientIdentifier},
399+
headers=headers,
395400
jwtToken=jwtToken,
396401
keypair=(privkey, pubkey),
397402
scopes=['username', 'email', 'friendly_name']
@@ -411,4 +416,4 @@ def test_myplex_jwt_login(account, tmp_path, monkeypatch):
411416
with pytest.raises(jwt.InvalidSignatureError):
412417
jwtlogin.decodePlexJWT()
413418

414-
device.delete()
419+
account.device(clientId=clientIdentifier).delete()

tests/test_video.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ def test_video_Movie_upload_select_remove_subtitle(movie, subtitle):
442442
pass
443443

444444

445+
@pytest.mark.xfail(reason="Plex's OpenSubtitles times out occasionally")
445446
def test_video_Movie_on_demand_subtitles(movie, account):
446447
movie_subtitles = movie.subtitleStreams()
447448
subtitles = movie.searchSubtitles()

0 commit comments

Comments
 (0)