--- /dev/null
+Python unit tests checking the output of the programs in aubio/examples/
--- /dev/null
+from template import *
+
+class aubionotes_test_case(program_test_case):
+
+ import os.path
+ filename = os.path.join('..','..','sounds','woodblock.aiff')
+ progname = os.path.join('..','..','examples','aubioonset')
+
+ def test_aubionotes(self):
+ """ test aubionotes with default parameters """
+ self.getOutput()
+ # FIXME: useless check
+ assert len(self.output) >= 0
+
+ def test_aubionotes_verbose(self):
+ """ test aubionotes with -v parameter """
+ self.command += " -v "
+ self.getOutput()
+ # FIXME: loose checking: make sure at least 8 lines are printed
+ assert len(self.output) >= 8
+
+ def test_aubionotes_devnull(self):
+ """ test aubionotes on /dev/null """
+ self.filename = "/dev/null"
+ # exit status should not be 0
+ self.getOutput(expected_status = -1)
+ assert self.status != 0
+ # and there should be an error message
+ assert len(self.output) > 0
+ # that looks like this
+ output_lines = self.output.split('\n')
+ assert output_lines[0] == "Unable to open input file /dev/null."
+ #assert output_lines[1] == "Supported file format but file is malformed."
+ assert output_lines[2] == "Could not open input file /dev/null."
+
+if __name__ == '__main__': unittest.main()
--- /dev/null
+from template import *
+
+class aubioonset_test_case(program_test_case):
+
+ import os.path
+ filename = os.path.join('..','..','sounds','woodblock.aiff')
+ progname = os.path.join('..','..','examples','aubioonset')
+
+ def test_aubioonset(self):
+ """ test aubioonset with default parameters """
+ self.getOutput()
+
+ def test_aubioonset_with_inf_silence(self):
+ """ test aubioonset with -s 0 """
+ self.command += " -s 0"
+ self.getOutput()
+ assert len(self.output) == 0, self.output
+
+ def test_aubioonset_with_no_silence(self):
+ """ test aubioonset with -s -100 """
+ self.command += " -s -100 "
+ self.getOutput()
+ # only one onset in woodblock.aiff
+ assert len(self.output.split('\n')) == 1
+ assert len(str(self.output)) != 0, "no output produced with command:\n" + self.command
+ # onset should be at 0.00000
+ assert float(self.output.strip()) == 0.
+
+class aubioonset_test_case_energy(aubioonset_test_case):
+ def setUp(self, options = " -O energy "):
+ aubioonset_test_case.setUp(self, options = options)
+
+class aubioonset_test_case_specdiff(aubioonset_test_case):
+ def setUp(self, options = " -O specdiff "):
+ aubioonset_test_case.setUp(self, options = options)
+
+class aubioonset_test_case_hfc(aubioonset_test_case):
+ def setUp(self, options = " -O hfc "):
+ aubioonset_test_case.setUp(self, options = options)
+
+class aubioonset_test_case_complex(aubioonset_test_case):
+ def setUp(self, options = " -O complex "):
+ aubioonset_test_case.setUp(self, options = options)
+
+class aubioonset_test_case_phase(aubioonset_test_case):
+ def setUp(self, options = " -O phase "):
+ aubioonset_test_case.setUp(self, options = options)
+
+class aubioonset_test_case_kl(aubioonset_test_case):
+ def setUp(self, options = " -O kl "):
+ aubioonset_test_case.setUp(self, options = options)
+
+class aubioonset_test_case_mkl(aubioonset_test_case):
+ def setUp(self, options = " -O mkl "):
+ aubioonset_test_case.setUp(self, options = options)
+
+if __name__ == '__main__':
+ unittest.main()
--- /dev/null
+import unittest
+from commands import getstatusoutput
+
+class program_test_case(unittest.TestCase):
+
+ filename = "/dev/null"
+ progname = "UNDEFINED"
+ command = ""
+
+ def setUp(self, options = ""):
+ self.options = options
+
+ def getOutput(self, expected_status = 0):
+ self.command = self.progname + ' -i ' + self.filename + self.command
+ self.command += self.options
+ [self.status, self.output] = getstatusoutput(self.command)
+ if expected_status != -1:
+ assert self.status == expected_status, \
+ "expected status was %s, got %s\nOutput was:\n%s" % \
+ (expected_status, self.status, self.output)
import unittest
from glob import glob
-modules_to_test = [i.split('.')[0] for i in glob('*.py')]
+def list_of_test_files(path):
+ return [i.split('.')[0].replace('/','.') for i in glob(path)]
+
+modules_to_test = list_of_test_files('*.py')
+modules_to_test += list_of_test_files('examples/aubio*.py')
if __name__ == '__main__':
for module in modules_to_test:
- if module != 'all_tests': # (not actually needed)
+ if module != 'run_all_tests': # (not actually needed)
exec('from %s import *' % module)
unittest.main()