run black on codebase
This commit is contained in:
@ -1,15 +1,16 @@
|
||||
from ziffers import *
|
||||
import pytest
|
||||
|
||||
|
||||
def test_can_parse():
|
||||
expressions = [
|
||||
"[1 [2 3]]",
|
||||
"(1 (1,3) 1..3)",
|
||||
"_^ q _qe^3 qww_4 _123 <1 2>",
|
||||
"q _2 _ 3 ^ 343",
|
||||
"2 qe2 e4",
|
||||
"q 2 <3 343>",
|
||||
"q (2 <3 343 (3 4)>)",
|
||||
"[1 [2 3]]",
|
||||
"(1 (1,3) 1..3)",
|
||||
"_^ q _qe^3 qww_4 _123 <1 2>",
|
||||
"q _2 _ 3 ^ 343",
|
||||
"2 qe2 e4",
|
||||
"q 2 <3 343>",
|
||||
"q (2 <3 343 (3 4)>)",
|
||||
]
|
||||
results = []
|
||||
for expression in expressions:
|
||||
@ -21,10 +22,11 @@ def test_can_parse():
|
||||
print(e)
|
||||
results.append(False)
|
||||
|
||||
# Return true if all the results are true (succesfully parsed)
|
||||
# Return true if all the results are true (succesfully parsed)
|
||||
print(results)
|
||||
assert all(results)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pattern",
|
||||
[
|
||||
@ -35,12 +37,13 @@ def test_can_parse():
|
||||
def test_parsing_text(pattern: str):
|
||||
assert parse_expression(pattern).text == pattern
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pattern,expected",
|
||||
[
|
||||
("1 2 3", [1,2,3]),
|
||||
("q2 eq3", [2,3]),
|
||||
("1 2 3", [1, 2, 3]),
|
||||
("q2 eq3", [2, 3]),
|
||||
],
|
||||
)
|
||||
def test_pcs(pattern: str, expected: list):
|
||||
assert parse_expression(pattern).pcs() == expected
|
||||
assert parse_expression(pattern).pcs() == expected
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
from ziffers import scale
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"name,expected",
|
||||
[
|
||||
@ -14,11 +15,37 @@ import pytest
|
||||
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]),
|
||||
(
|
||||
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
|
||||
assert [
|
||||
scale.note_from_pc(root=60, pitch_class=val, intervals="Ionian") for val in pcs
|
||||
] == expected
|
||||
|
||||
Reference in New Issue
Block a user