-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests for the parselmouth.praat.run interface
- Loading branch information
1 parent
a8204b2
commit 2893d90
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import pytest | ||
|
||
import parselmouth | ||
|
||
|
||
def test_run_script(resources): | ||
script = """ | ||
Read from file: "{}" | ||
To Intensity: 100.0, 0.0, "yes" | ||
selectObject: 1 | ||
selectObject: "Intensity the_north_wind_and_the_sun" | ||
""".format(resources["the_north_wind_and_the_sun.wav"]) | ||
|
||
assert parselmouth.praat.run(script)[0] == parselmouth.Sound(resources["the_north_wind_and_the_sun.wav"]).to_intensity() | ||
|
||
with pytest.raises(parselmouth.PraatError, match="Found 3 arguments but expected only 0."): | ||
parselmouth.praat.run(script, 42, "some_argument", True) | ||
|
||
|
||
def test_run_script_with_parameters(resources): | ||
script = """ | ||
form Test | ||
positive minPitch 100.0 | ||
real timeStep 0.0 | ||
boolean subtractMean "yes" | ||
endform | ||
Read from file: "{}" | ||
To Intensity: minPitch, timeStep, subtractMean | ||
selectObject: 1 | ||
selectObject: "Intensity the_north_wind_and_the_sun" | ||
""".format(resources["the_north_wind_and_the_sun.wav"]) | ||
|
||
min_pitch = 75.0 | ||
time_step = 0.05 | ||
subtract_mean = False | ||
|
||
assert parselmouth.praat.run(script, min_pitch, time_step, subtract_mean)[0] == parselmouth.Sound(resources["the_north_wind_and_the_sun.wav"]).to_intensity(min_pitch, time_step, subtract_mean) | ||
|
||
with pytest.raises(parselmouth.PraatError, match="Found 0 arguments but expected more."): | ||
parselmouth.praat.run(script) |