Skip to content

Commit

Permalink
Test --clean option
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef-Friedrich committed Jan 19, 2024
1 parent 8f3073c commit ce0b556
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
8 changes: 3 additions & 5 deletions mscxyz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,9 @@ def list_styles(version: int) -> None:

# style

if args.style_clean:
score.style.clean()

for style_name, value in args.style_value:
score.style.set(style_name, value)

Expand Down Expand Up @@ -750,11 +753,6 @@ def list_styles(version: int) -> None:

# print("\n" + utils.color(file, "red"))

# if args.subcommand == "clean":
# score = Score(file)
# print(score.filename)
# score.clean()

# elif args.subcommand == "lyrics":
# score = Score(file)
if args.lyrics_remap:
Expand Down
36 changes: 32 additions & 4 deletions tests/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ def test_method_set_all(styles: str) -> None:


class TestClean:
def test_clean(self) -> None:
@pytest.mark.legacy
def test_clean_legacy(self) -> None:
c = Cli("clean", legacy=True).append_score("formats.mscz").execute()

uncleaned: str = c.pre.read_as_text()
Expand All @@ -336,14 +337,41 @@ def test_clean(self) -> None:
assert "<LayoutBreak>" not in cleaned
assert "<StemDirection>" not in cleaned

def test_clean_add_style(self) -> None:
def test_clean(self) -> None:
c = Cli("--clean").append_score("formats.mscz").execute()

uncleaned: str = c.pre.read_as_text()
assert "<font" in uncleaned
assert "<b>" in uncleaned
assert "<i>" in uncleaned
# assert "<pos" in uncleaned
assert "<LayoutBreak>" in uncleaned
assert "<StemDirection>" in uncleaned

cleaned: str = c.post.read_as_text()
assert "<font" not in cleaned
assert "<b>" not in cleaned
assert "<i>" not in cleaned
assert "<pos" not in cleaned
assert "<LayoutBreak>" not in cleaned
assert "<StemDirection>" not in cleaned

@pytest.mark.legacy
def test_clean_add_style_legacy(self) -> None:
score = (
Cli("clean", "--style", helper.get_score("style.mss", 2), legacy=True)
.append_score("simple.mscx", 2)
.score()
)
style = score.read_as_text()
assert "<staffUpperBorder>77</staffUpperBorder>" in style
assert "<staffUpperBorder>77</staffUpperBorder>" in score.read_as_text()

def test_clean_add_style(self) -> None:
score = (
Cli("--clean", "--style-file", helper.get_file("Jazz.mss", 4))
.append_score("score.mscz")
.score()
)
assert "<musicalSymbolFont>MuseJazz</musicalSymbolFont>" in score.read_as_text()


def test_load_style_file() -> None:
Expand Down

0 comments on commit ce0b556

Please sign in to comment.