From 767a83fbe6aa757b84e74235976a2203bcc9a4a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?=
Date: Thu, 3 Oct 2024 10:02:51 +0100
Subject: [PATCH] Refactor utils test cases to use pytest.mark.parametrize
---
test/plugins/test_lyrics.py | 58 ++++++++++++++++++++-----------------
1 file changed, 31 insertions(+), 27 deletions(-)
diff --git a/test/plugins/test_lyrics.py b/test/plugins/test_lyrics.py
index 68c1a33b8..fbf4a984a 100644
--- a/test/plugins/test_lyrics.py
+++ b/test/plugins/test_lyrics.py
@@ -91,38 +91,42 @@ class TestLyricsUtils:
assert list(actual_titles) == [title, *expected_extra_titles]
- def test_remove_credits(self):
- assert (
- lyrics.remove_credits(
- """It's close to midnight
- Lyrics brought by example.com"""
- )
- == "It's close to midnight"
- )
- assert lyrics.remove_credits("""Lyrics brought by example.com""") == ""
+ @pytest.mark.parametrize(
+ "initial_lyrics, expected",
+ [
+ ("Verse\nLyrics credit in the last line", "Verse"),
+ ("Lyrics credit in the first line\nVerse", "Verse"),
+ (
+ """Verse
+ Lyrics mentioned somewhere in the middle
+ Verse""",
+ """Verse
+ Lyrics mentioned somewhere in the middle
+ Verse""",
+ ),
+ ],
+ )
+ def test_remove_credits(self, initial_lyrics, expected):
+ assert lyrics.remove_credits(initial_lyrics) == expected
- # don't remove 2nd verse for the only reason it contains 'lyrics' word
- text = """Look at all the shit that i done bought her
- See lyrics ain't nothin
- if the beat aint crackin"""
- assert lyrics.remove_credits(text) == text
-
- def test_scrape_strip_cruft(self):
- text = """
+ @pytest.mark.parametrize(
+ "initial_text, expected",
+ [
+ (
+ """
one
two !
- """
- assert lyrics._scrape_strip_cruft(text, True) == "one\ntwo !\n\nfour"
-
- def test_scrape_strip_scripts(self):
- text = """foobaz"""
- assert lyrics._scrape_strip_cruft(text, True) == "foobaz"
-
- def test_scrape_strip_tag_in_comment(self):
- text = """fooqux"""
- assert lyrics._scrape_strip_cruft(text, True) == "fooqux"
+ """,
+ "one\ntwo !\n\nfour",
+ ),
+ ("foobaz", "foobaz"),
+ ("fooqux", "fooqux"),
+ ],
+ )
+ def test_scrape_strip_cruft(self, initial_text, expected):
+ assert lyrics._scrape_strip_cruft(initial_text, True) == expected
def test_scrape_merge_paragraphs(self):
text = "one
two
three"