[d6f515d] | 1 | from template import * |
---|
| 2 | |
---|
| 3 | import os.path |
---|
| 4 | |
---|
| 5 | class aubiopitch_test_case(program_test_case): |
---|
| 6 | |
---|
| 7 | import os.path |
---|
| 8 | filename = os.path.join('..','..','sounds','woodblock.aiff') |
---|
| 9 | progname = "PYTHONPATH=../../python:../../python/aubio/.libs " + \ |
---|
| 10 | os.path.join('..','..','python','aubiopitch') |
---|
| 11 | |
---|
| 12 | def test_aubiopitch(self): |
---|
| 13 | """ test aubiopitch with default parameters """ |
---|
| 14 | self.getOutput() |
---|
| 15 | # FIXME: useless check |
---|
| 16 | self.assertEqual(len(self.output.split('\n')), 1) |
---|
| 17 | #self.assertEqual(float(self.output.strip()), 0.) |
---|
| 18 | |
---|
| 19 | def test_aubiopitch_verbose(self): |
---|
| 20 | """ test aubiopitch with -v parameter """ |
---|
| 21 | self.command += " -v " |
---|
| 22 | self.getOutput() |
---|
| 23 | # FIXME: loose checking: make sure at least 8 lines are printed |
---|
| 24 | assert len(self.output) >= 8 |
---|
| 25 | |
---|
| 26 | def test_aubiopitch_devnull(self): |
---|
| 27 | """ test aubiopitch on /dev/null """ |
---|
| 28 | self.filename = "/dev/null" |
---|
| 29 | # exit status should not be 0 |
---|
| 30 | self.getOutput(expected_status = 256) |
---|
| 31 | # and there should be an error message |
---|
| 32 | assert len(self.output) > 0 |
---|
| 33 | # that looks like this |
---|
| 34 | output_lines = self.output.split('\n') |
---|
| 35 | #assert output_lines[0] == "Unable to open input file /dev/null." |
---|
| 36 | #assert output_lines[1] == "Supported file format but file is malformed." |
---|
| 37 | #assert output_lines[2] == "Could not open input file /dev/null." |
---|
| 38 | |
---|
| 39 | mode_names = ["yinfft", "yin", "fcomb", "mcomb", "schmitt"] |
---|
| 40 | for name in mode_names: |
---|
| 41 | exec("class aubiopitch_test_case_" + name + "(aubiopitch_test_case):\n\ |
---|
| 42 | options = \" -m " + name + " \"") |
---|
| 43 | |
---|
| 44 | class aubiopitch_test_yinfft(program_test_case): |
---|
| 45 | |
---|
| 46 | filename = os.path.join('..','..','sounds','16568_acclivity_TwoCows.wav') |
---|
| 47 | progname = "PYTHONPATH=../../python:../../python/aubio/.libs " + \ |
---|
| 48 | os.path.join('..','..','python','aubiopitch') |
---|
| 49 | options = " -m yinfft -t 0.75 " |
---|
| 50 | |
---|
| 51 | def test_aubiopitch(self): |
---|
| 52 | """ test aubiopitch with default parameters """ |
---|
| 53 | self.getOutput() |
---|
| 54 | expected_output = open(os.path.join('examples','aubiopitch','yinfft'+'.'+os.path.basename(self.filename)+'.txt')).read() |
---|
| 55 | for line_out, line_exp in zip(self.output.split('\n'), expected_output.split('\n')): |
---|
| 56 | assert line_out == line_exp, line_exp + " vs. " + line_out |
---|
| 57 | |
---|
| 58 | if __name__ == '__main__': unittest.main() |
---|