5 class aubiopitch_test_case(program_test_case):
8 filename = os.path.join('..','..','sounds','woodblock.aiff')
9 progname = "PYTHONPATH=../../python:../../python/aubio/.libs " + \
10 os.path.join('..','..','python','aubiopitch')
12 def test_aubiopitch(self):
13 """ test aubiopitch with default parameters """
15 # FIXME: useless check
16 self.assertEqual(len(self.output.split('\n')), 1)
17 #self.assertEqual(float(self.output.strip()), 0.)
19 def test_aubiopitch_verbose(self):
20 """ test aubiopitch with -v parameter """
21 self.command += " -v "
23 # FIXME: loose checking: make sure at least 8 lines are printed
24 assert len(self.output) >= 8
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."
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 + " \"")
44 class aubiopitch_test_yinfft(program_test_case):
46 filename = os.path.join('..','..','sounds','16568__acclivity__TwoCows.wav')
47 url = "http://www.freesound.org/samplesViewSingle.php?id=16568"
48 progname = "PYTHONPATH=../../python:../../python/aubio/.libs " + \
49 os.path.join('..','..','python','aubiopitch')
50 options = " -m yinfft -t 0.75 "
52 def test_aubiopitch(self):
53 """ test aubiopitch with default parameters """
54 if not os.path.isfile(self.filename):
55 print "Warning: file 16568_acclivity_TwoCows.wav was not found in %s" % os.path.dirname(self.filename)
56 print "download it from %s to actually run test" % url
59 expected_output = open(os.path.join('examples','aubiopitch','yinfft'+'.'+os.path.basename(self.filename)+'.txt')).read()
61 for line_out, line_exp in zip(self.output.split('\n'), expected_output.split('\n')):
63 assert line_exp == line_out, line_exp + " vs. " + line_out + " at line " + str(lines)
65 open(os.path.join('examples','aubiopitch','yinfft'+'.'+os.path.basename(self.filename)+'.txt.out'),'w').write(self.output)
69 if __name__ == '__main__': unittest.main()