mirror of
https://github.com/beetbox/beets.git
synced 2025-12-07 09:04:33 +01:00
Fix substitute test formatting
This commit is contained in:
parent
16ac231f7f
commit
876dcb9bee
1 changed files with 12 additions and 22 deletions
|
|
@ -14,12 +14,12 @@
|
||||||
|
|
||||||
"""Test the substitute plugin regex functionality."""
|
"""Test the substitute plugin regex functionality."""
|
||||||
|
|
||||||
|
|
||||||
from beets.test.helper import PluginTestCase
|
from beets.test.helper import PluginTestCase
|
||||||
from beetsplug.substitute import Substitute
|
from beetsplug.substitute import Substitute
|
||||||
|
|
||||||
PLUGIN_NAME = "substitute"
|
PLUGIN_NAME = "substitute"
|
||||||
|
|
||||||
|
|
||||||
class SubstitutePluginTest(PluginTestCase):
|
class SubstitutePluginTest(PluginTestCase):
|
||||||
plugin = "substitute"
|
plugin = "substitute"
|
||||||
preload_plugin = False
|
preload_plugin = False
|
||||||
|
|
@ -32,42 +32,33 @@ class SubstitutePluginTest(PluginTestCase):
|
||||||
"c": "d",
|
"c": "d",
|
||||||
}
|
}
|
||||||
):
|
):
|
||||||
cases = [
|
cases = [("a", "b"), ("b", "c"), ("c", "d")]
|
||||||
("a", "b"),
|
|
||||||
("b", "c"),
|
|
||||||
("c", "d")
|
|
||||||
]
|
|
||||||
for input, expected in cases:
|
for input, expected in cases:
|
||||||
assert Substitute().tmpl_substitute(input) == expected
|
assert Substitute().tmpl_substitute(input) == expected
|
||||||
|
|
||||||
def test_case_insensitivity(self):
|
def test_case_insensitivity(self):
|
||||||
with self.configure_plugin(
|
with self.configure_plugin({"a": "b"}):
|
||||||
{ "a": "b" }
|
|
||||||
):
|
|
||||||
assert Substitute().tmpl_substitute("A") == "b"
|
assert Substitute().tmpl_substitute("A") == "b"
|
||||||
|
|
||||||
def test_unmatched_input_preserved(self):
|
def test_unmatched_input_preserved(self):
|
||||||
with self.configure_plugin(
|
with self.configure_plugin({"a": "b"}):
|
||||||
{ "a": "b" }
|
|
||||||
):
|
|
||||||
assert Substitute().tmpl_substitute("c") == "c"
|
assert Substitute().tmpl_substitute("c") == "c"
|
||||||
|
|
||||||
def test_regex_to_static(self):
|
def test_regex_to_static(self):
|
||||||
with self.configure_plugin(
|
with self.configure_plugin({".*jimi hendrix.*": "Jimi Hendrix"}):
|
||||||
{ ".*jimi hendrix.*": "Jimi Hendrix" }
|
|
||||||
):
|
|
||||||
result = Substitute().tmpl_substitute("The Jimi Hendrix Experience")
|
result = Substitute().tmpl_substitute("The Jimi Hendrix Experience")
|
||||||
assert result == "Jimi Hendrix"
|
assert result == "Jimi Hendrix"
|
||||||
|
|
||||||
def test_regex_capture_group(self):
|
def test_regex_capture_group(self):
|
||||||
with self.configure_plugin(
|
with self.configure_plugin({"^(.*?)(,| &| and).*": r"\1"}):
|
||||||
{ "^(.*?)(,| &| and).*": r"\1" }
|
|
||||||
):
|
|
||||||
cases = [
|
cases = [
|
||||||
("King Creosote & Jon Hopkins", "King Creosote"),
|
("King Creosote & Jon Hopkins", "King Creosote"),
|
||||||
("Michael Hurley, The Holy Modal Rounders,"
|
(
|
||||||
+ "Jeffrey Frederick & The Clamtones", "Michael Hurley"),
|
"Michael Hurley, The Holy Modal Rounders, Jeffrey Frederick & "
|
||||||
("James Yorkston and the Athletes", "James Yorkston")
|
+ "The Clamtones",
|
||||||
|
"Michael Hurley",
|
||||||
|
),
|
||||||
|
("James Yorkston and the Athletes", "James Yorkston"),
|
||||||
]
|
]
|
||||||
for input, expected in cases:
|
for input, expected in cases:
|
||||||
assert Substitute().tmpl_substitute(input) == expected
|
assert Substitute().tmpl_substitute(input) == expected
|
||||||
|
|
@ -84,7 +75,6 @@ class SubstitutePluginTest(PluginTestCase):
|
||||||
for input, expected in cases:
|
for input, expected in cases:
|
||||||
assert Substitute().tmpl_substitute(input) == expected
|
assert Substitute().tmpl_substitute(input) == expected
|
||||||
|
|
||||||
|
|
||||||
def test_break_on_first_match(self):
|
def test_break_on_first_match(self):
|
||||||
with self.configure_plugin(
|
with self.configure_plugin(
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue