Skip to content

Commit

Permalink
Adding tests for the parselmouth.praat.run interface
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickJadoul committed Aug 9, 2018
1 parent a8204b2 commit 2893d90
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_praat.py
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)

0 comments on commit 2893d90

Please sign in to comment.