Added tests for scale
Added option to give intervals as scale name
This commit is contained in:
@ -43,4 +43,4 @@ def test_parsing_text(pattern: str):
|
||||
],
|
||||
)
|
||||
def test_pcs(pattern: str, expected: list):
|
||||
assert parse_expression(pattern).pcs == expected
|
||||
assert parse_expression(pattern).pcs() == expected
|
||||
24
tests/test_scale.py
Normal file
24
tests/test_scale.py
Normal file
@ -0,0 +1,24 @@
|
||||
from ziffers import scale
|
||||
import pytest
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"name,expected",
|
||||
[
|
||||
("C4", 60),
|
||||
("A1", 33),
|
||||
("Bb3", 58),
|
||||
("C#1", 25),
|
||||
("foo", 60),
|
||||
],
|
||||
)
|
||||
def test_notenames(name: str, expected: int):
|
||||
assert scale.note_to_midi(name) == expected
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pcs,expected",
|
||||
[
|
||||
(list(range(-9,10)), [45, 47, 48, 50, 52, 53, 55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72, 74, 76]),
|
||||
],
|
||||
)
|
||||
def test_note_to_midi(pcs: str, expected: int):
|
||||
assert [scale.note_from_pc(root=60, pitch_class=val, intervals="Ionian") for val in pcs] == expected
|
||||
Reference in New Issue
Block a user