Skip to content

Commit

Permalink
Fix Ruff format errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nanonanomachine committed Mar 9, 2025
1 parent 496c4f0 commit b381986
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
42 changes: 21 additions & 21 deletions tests/test_external_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ def test_preset_parameters(plugin_filename: str, plugin_preset: str):
actual = getattr(plugin, name)
if math.isnan(actual):
continue
assert (
actual != default
), f"Expected attribute {name} to be different from default ({default}), but was {actual}"
assert actual != default, (
f"Expected attribute {name} to be different from default ({default}), but was {actual}"
)


@pytest.mark.skipif(
Expand All @@ -322,9 +322,9 @@ def test_get_vst3_preset(plugin_filename: str):
plugin = load_test_plugin(plugin_filename)
preset_data: bytes = plugin.preset_data

assert (
preset_data[:4] == b"VST3"
), "Preset data for {plugin_filename} is not in .vstpreset format"
assert preset_data[:4] == b"VST3", (
"Preset data for {plugin_filename} is not in .vstpreset format"
)
# Check that the class ID (8 bytes into the data) is a 32-character hex string.
cid = preset_data[8:][:32]
assert all(c in b"0123456789ABCDEF" for c in cid), f"CID contains invalid characters: {cid}"
Expand All @@ -333,17 +333,17 @@ def test_get_vst3_preset(plugin_filename: str):
@pytest.mark.skipif(not plugin_named("Magical8BitPlug"), reason="Missing Magical8BitPlug 2 plugin.")
def test_set_vst3_preset():
plugin_file = plugin_named("Magical8BitPlug")
assert (
plugin_file is not None and "vst3" in plugin_file
), f"Expected a vst plugin: {plugin_file}"
assert plugin_file is not None and "vst3" in plugin_file, (
f"Expected a vst plugin: {plugin_file}"
)
plugin = load_test_plugin(plugin_file)

# Pick a known valid value for one of the plugin parameters.
default_gain_value = plugin.gain
new_gain_value = 1.0
assert (
default_gain_value != new_gain_value
), f"Expected default gain to be different than {new_gain_value}"
assert default_gain_value != new_gain_value, (
f"Expected default gain to be different than {new_gain_value}"
)

# Update the parameter and get the resulting .vstpreset bytes.
plugin.gain = new_gain_value
Expand All @@ -353,17 +353,17 @@ def test_set_vst3_preset():
plugin.gain = default_gain_value

# Sanity check that the parameter was successfully set.
assert (
plugin.gain == default_gain_value
), f"Expected gain to be reset to {default_gain_value}, but got {plugin.gain}"
assert plugin.gain == new_gain_value, (
f"Expected gain to be {new_gain_value}, but got {plugin.gain}"
)

# Load the .vstpreset bytes and make sure the parameter was
# updated.
plugin.preset_data = preset_data

assert (
plugin.gain == new_gain_value
), f"Expected gain to be {new_gain_value}, but got {plugin.gain}"
assert plugin.gain == new_gain_value, (
f"Expected gain to be {new_gain_value}, but got {plugin.gain}"
)


@pytest.mark.parametrize("plugin_filename", AVAILABLE_PLUGINS_IN_TEST_ENVIRONMENT)
Expand Down Expand Up @@ -832,9 +832,9 @@ def test_plugin_parameters_persist_between_calls(plugin_filename: str):
plugin.process(noise, sr)

for name, parameter in plugin.parameters.items():
assert (
getattr(plugin, name) == expected_values[name]
), f"Expected {name} to match saved value"
assert getattr(plugin, name) == expected_values[name], (
f"Expected {name} to match saved value"
)


@pytest.mark.parametrize("plugin_filename", sample(AVAILABLE_EFFECT_PLUGINS_IN_TEST_ENVIRONMENT, 1))
Expand Down
6 changes: 3 additions & 3 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,9 @@ def test_swapped_parameter_exception(tmp_path: pathlib.Path, extension: str, sam
filename = str(tmp_path / f"test{extension}")
with pytest.raises(ValueError) as e:
pedalboard.io.WriteableAudioFile(filename, samplerate=1, num_channels=samplerate)
assert "reversing" in str(
e
), "Expected exception to include details about reversing parameters."
assert "reversing" in str(e), (
"Expected exception to include details about reversing parameters."
)


@pytest.mark.parametrize("dtype", [np.uint8, np.uint16, np.uint32, np.uint64])
Expand Down
4 changes: 2 additions & 2 deletions tests/test_stream_resampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def test_returned_sample_count(

for i, (e, a) in enumerate(zip(expected_output[0], output[0])):
assert e == a, (
f"First mismatch at index {i}:\nExpected: [..., {expected_output[0][i - 2: i + 2]},"
f" ...]\nActual: [..., {output[0][i - 2: i + 2]}, ...]"
f"First mismatch at index {i}:\nExpected: [..., {expected_output[0][i - 2 : i + 2]},"
f" ...]\nActual: [..., {output[0][i - 2 : i + 2]}, ...]"
)

assert output.shape[1] == expected_output.shape[1], (
Expand Down

0 comments on commit b381986

Please sign in to comment.