Skip to content

Commit

Permalink
Move tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef-Friedrich committed Jan 26, 2024
1 parent 9c76f4f commit 4bbfc04
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
master_doc = "index"

project = "mscxyz"
copyright = "2016 - 2023, Josef Friedrich"
copyright = "2016 - 2024, Josef Friedrich"
author = "Josef Friedrich"
version: str = mscxyz.__version__
release: str = mscxyz.__version__
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def score4z() -> Score:
return helper.get_score("score.mscz", version=4)


@pytest.fixture(autouse=True)
@pytest.fixture(autouse=True, scope="function")
def score() -> Score:
"""Instantiate a Score object from the file simple.mscz (version 4)."""
return helper.get_score("score.mscz", version=4)
Expand Down
32 changes: 10 additions & 22 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

from __future__ import annotations

from pathlib import Path

import pytest
from lxml.etree import _Element

from mscxyz import Score, list_files
from mscxyz import Score


def test_instantiate_a_score_object(score_file: str) -> None:
Expand All @@ -31,23 +29,9 @@ def print_elements(element: _Element, level: int) -> None:
print_elements(score.xml_root, 0)


def test_list_files(nested_dir: Path) -> None:
score_paths: list[str] = []
for score_path in list_files(src=str(nested_dir), extension="mscz"):
score = Score(score_path)
assert score.path.exists()
assert score.extension == "mscz"
score_paths.append(str(score_path))

assert len(score_paths) == 4

assert "level1/level2/level3/score3.mscz" in score_paths[3]
assert "level1/level2/score2.mscz" in score_paths[2]
assert "level1/score1.mscz" in score_paths[1]
assert "score0.mscz" in score_paths[0]


@pytest.mark.skip("Will be fixed later")
@pytest.mark.skip(
"Strange error! Fails in tox make test ... but works in vscode and with pytest -k test_set_meta_tag_title"
)
def test_set_meta_tag_composer(score: Score) -> None:
assert score.meta.metatag.composer == "Composer"

Expand All @@ -58,7 +42,9 @@ def test_set_meta_tag_composer(score: Score) -> None:
assert new_score.meta.metatag.composer == "Mozart"


@pytest.mark.skip("Will be fixed later")
@pytest.mark.skip(
"Strange error! Fails in tox make test ... but works in vscode and with pytest -k test_set_meta_tag_title"
)
def test_set_all_font_faces_using_for_loop(score: Score) -> None:
assert score.style.get("defaultFontFace") == "FreeSerif"

Expand All @@ -71,7 +57,9 @@ def test_set_all_font_faces_using_for_loop(score: Score) -> None:
assert new_score.style.get("defaultFontFace") == "Alegreya"


@pytest.mark.skip("Will be fixed later")
@pytest.mark.skip(
"Strange error! Fails in tox make test ... but works in vscode and with pytest -k test_set_meta_tag_title"
)
def test_set_all_font_faces_using_method(score: Score) -> None:
assert score.style.get("defaultFontFace") == "FreeSerif"

Expand Down
18 changes: 17 additions & 1 deletion tests/test_how_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from mscxyz import Score
from mscxyz import Score, list_files
from tests import helper
from tests.helper import Cli, assert_file_type

Expand Down Expand Up @@ -94,6 +94,22 @@ def test_dont_mix_mscx_and_glob(self) -> None:
)


def test_list_files(nested_dir: Path) -> None:
score_paths: list[str] = []
for score_path in list_files(src=str(nested_dir), extension="mscz"):
score = Score(score_path)
assert score.path.exists()
assert score.extension == "mscz"
score_paths.append(str(score_path))

assert len(score_paths) == 4

assert "level1/level2/level3/score3.mscz" in score_paths[3]
assert "level1/level2/score2.mscz" in score_paths[2]
assert "level1/score1.mscz" in score_paths[1]
assert "score0.mscz" in score_paths[0]


@pytest.mark.slow
@pytest.mark.skipif(
helper.mscore_executable is None, reason="mscore executable not found"
Expand Down

0 comments on commit 4bbfc04

Please sign in to comment.