def test_hz_to_period_zero():
    expected = ValueError
    assert toymir.hz_to_midi(0) == expected
    expected = [261.6255653, 329.62755691, 440.0]
    assert np.allclose(toymir.midi_to_hz([60, 64, 69]), expected)


# Hello, you're probably at the start of Part 5!
# These are the two tests you should uncomment!


 def test_hz_to_midi_float():
     expected = 69
     assert toymir.hz_to_midi(440.0) == expected


 def test_hz_to_midi_array():
     expected = [57, 69, 81]
    assert np.allclose(toymir.hz_to_midi([220.0, 440.0, 880.0]), expected)


# Hello!  You could add the missing test for test_hz_to_midi here!

def test_hz_to_period_zero():
    expected = ValueError
    assert toymir.hz_to_midi(0) == expected


def test_hz_to_period_float():
    expected = 0.1
    assert toymir.hz_to_period(10) == expected


def test_hz_to_period_array():
 def test_hz_to_midi_float():
     expected = 69
     assert toymir.hz_to_midi(440.0) == expected
Ejemplo n.º 4
0
def test_hz_to_midi_array():
    expected = [57, 69, 81]
    assert np.allclose(toymir.hz_to_midi([220.0, 440.0, 880.0]), expected)
Ejemplo n.º 5
0
def test_hz_to_midi_throws_if_zero_or_less():
    # The test will pass if code inside the `with` block raises a ValueError!
    with pytest.raises(ValueError):
        toymir.hz_to_midi(0)
        toymir.hz_to_midi(-1)
Ejemplo n.º 6
0
def test_hz_to_midi_throws_if_zero_or_less():
    with pytest.raises(ValueError):
        toymir.hz_to_midi(0)
Ejemplo n.º 7
0
def test_hz_to_midi_throws_if_zero_or_less():
    # This is a bit magic-looking, but all it is saying is that
    # the test will pass if code inside the `with` block raises a ValueError!
    with pytest.raises(ValueError):
        toymir.hz_to_midi(0)
def test_hz_to_midi_exception_when_lteq_zero():
    with pytest.raises(ValueError):
        toymir.hz_to_midi(0)