From: Paul Brossier Date: Thu, 1 Nov 2007 15:40:15 +0000 (+0100) Subject: simplified examples template X-Git-Tag: bzr2git~495 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=100f950c3a113aab914a8a828445e8b6d2b63224;p=aubio.git simplified examples template --- diff --git a/tests/python/examples/aubionotes.py b/tests/python/examples/aubionotes.py index 9fdf4a60..6c22a349 100644 --- a/tests/python/examples/aubionotes.py +++ b/tests/python/examples/aubionotes.py @@ -4,13 +4,14 @@ class aubionotes_test_case(program_test_case): import os.path filename = os.path.join('..','..','sounds','woodblock.aiff') - progname = os.path.join('..','..','examples','aubioonset') + progname = os.path.join('..','..','examples','aubionotes') def test_aubionotes(self): """ test aubionotes with default parameters """ self.getOutput() # FIXME: useless check - assert len(self.output) >= 0 + self.assertEqual(len(self.output.split('\n')), 1) + self.assertEqual(float(self.output.strip()), 0.017415) def test_aubionotes_verbose(self): """ test aubionotes with -v parameter """ @@ -23,8 +24,7 @@ class aubionotes_test_case(program_test_case): """ test aubionotes on /dev/null """ self.filename = "/dev/null" # exit status should not be 0 - self.getOutput(expected_status = -1) - assert self.status != 0 + self.getOutput(expected_status = 256) # and there should be an error message assert len(self.output) > 0 # that looks like this @@ -33,4 +33,9 @@ class aubionotes_test_case(program_test_case): #assert output_lines[1] == "Supported file format but file is malformed." assert output_lines[2] == "Could not open input file /dev/null." +mode_names = ["yinfft", "yin", "fcomb", "mcomb", "schmitt"] +for name in mode_names: + exec("class aubionotes_test_case_" + name + "(aubionotes_test_case):\n\ + options = \" -p " + name + " \"") + if __name__ == '__main__': unittest.main() diff --git a/tests/python/examples/aubioonset.py b/tests/python/examples/aubioonset.py index e40d23c3..6d14141b 100644 --- a/tests/python/examples/aubioonset.py +++ b/tests/python/examples/aubioonset.py @@ -9,7 +9,6 @@ class aubioonset_test_case(program_test_case): def test_aubioonset(self): """ test aubioonset with default parameters """ self.getOutput() - assert len(self.output) != 0, self.output assert len(str(self.output)) != 0, "no output produced with command:\n" \ + self.command @@ -24,40 +23,14 @@ class aubioonset_test_case(program_test_case): 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 + assert len(self.output.split('\n')) == 1 # 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__': +for name in ["energy", "specdiff", "hfc", "complex", "phase", "kl", "mkl"]: + exec("class aubioonset_test_case_"+name+"(aubioonset_test_case):\n\ + options = \" -O "+name+" \"") - unittest.main() +if __name__ == '__main__': unittest.main() diff --git a/tests/python/examples/template.py b/tests/python/examples/template.py index 65f3f20a..a30e08e0 100644 --- a/tests/python/examples/template.py +++ b/tests/python/examples/template.py @@ -6,9 +6,7 @@ class program_test_case(unittest.TestCase): filename = "/dev/null" progname = "UNDEFINED" command = "" - - def setUp(self, options = ""): - self.options = options + options = "" def getOutput(self, expected_status = 0): self.command = self.progname + ' -i ' + self.filename + self.command