コード例 #1
0
def test_getfilecontent_normal():
    with open('test.json', 'w') as jsonfile:
        jsonfile.write(
            '{"version":2,"length":10,"data":[-7,7,-10,-1,-4,6,-2,9,-3,3,1,6,-9,7,-9,-2,-2,8,-1,7]}'
        )
    assert audio.get_file_content('test.json')["length"] == 10
    assert audio.get_file_content('test.json')["version"] == 2
    assert audio.get_file_content('test.json')["data"] == [
        -7, 7, -10, -1, -4, 6, -2, 9, -3, 3, 1, 6, -9, 7, -9, -2, -2, 8, -1, 7
    ]
コード例 #2
0
def test_removenegativevalue_no_data_index():
    with open('test.json', 'w') as jsonfile:
        jsonfile.write(
            '{"version":2,"length":10,"notdata":[-7,7,-10,-1,-4,6,-2,9,-3,3,1,6,-9,7,-9,-2,-2,8,-1,7]}'
        )
    with pytest.raises(KeyError):
        audio.remove_negative_value(audio.get_file_content('test.json'))
コード例 #3
0
def test_removenegativevalue_odd_number_of_value():
    with open('test.json', 'w') as jsonfile:
        jsonfile.write(
            '{"version":2,"length":10,"data":[-7,7,-10,-1,-4,6,-2,9,-3,3,1,6,-9,7,-9,-2,-2,8,-1]}'
        )
    assert audio.remove_negative_value(
        audio.get_file_content('test.json')) == [7, -1, 6, 9, 3, 6, 7, -2, 8]
コード例 #4
0
def test_removenegativevalue_normal():
    assert audio.remove_negative_value(
        audio.get_file_content('test.json')) == [
            7, -1, 6, 9, 3, 6, 7, -2, 8, 7
        ]
コード例 #5
0
def test_getfilecontent_no_file():
    with pytest.raises(IOError):
        audio.get_file_content('NoFileIsNamedLikeThis')