Fixed some bugs and added new tests
New test_multi_03 can be used to test multiple variables at once. Based on new collect function that can be used to collect n variables from parsed Ziffers.
This commit is contained in:
51
tests/test_scale_01.py
Normal file
51
tests/test_scale_01.py
Normal file
@ -0,0 +1,51 @@
|
||||
""" Tests for the scale module """
|
||||
import pytest
|
||||
from ziffers import scale
|
||||
|
||||
@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_name_to_midi(name) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pitch_classes,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(pitch_classes: str, expected: int):
|
||||
assert [
|
||||
scale.note_from_pc(root=60, pitch_class=val, intervals="Ionian") for val in pitch_classes
|
||||
] == expected
|
||||
Reference in New Issue
Block a user