Skip to content

Commit 4f285ff

Browse files
Add a regression test for issue #4631
1 parent 52027cb commit 4f285ff

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# pylint: disable=import-error,missing-function-docstring,unused-variable
2+
3+
"""
4+
Regression tests for StopIteration raised when using limit-inference-results=0
5+
"""
6+
7+
import typing
8+
9+
from ytmusicapi import YTMusic # [unused-import]
10+
11+
12+
def get_youtube_link(
13+
song_name: str, song_artists: typing.List[str]
14+
) -> typing.Optional[str]:
15+
# +1: [undefined-variable]
16+
ytm_results = __query_ytmusic(song_name=song_name, song_artists=song_artists)
17+
top_match_score = 0
18+
top_result = None
19+
if top_match_score <= 0.75:
20+
if top_result is not None:
21+
with open("possible errors.txt", "ab") as file:
22+
file.write(
23+
f"{', '.join(song_artists)} - {song_name}\n {top_match_score:0.2f}pt "
24+
f"{top_result['link']}: {top_result['name']}\n".encode()
25+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[testoptions]
2+
limit-inference-results=0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
unused-import:9:0::Unused YTMusic imported from ytmusicapi:HIGH
2+
undefined-variable:16:18:get_youtube_link:Undefined variable '__query_ytmusic':HIGH

0 commit comments

Comments
 (0)