ref: 100f950c3a113aab914a8a828445e8b6d2b63224
parent: cea30b8952f7aa2d7f5c4c8b27f34f1ee1fb5053
author: Paul Brossier <piem@piem.org>
date: Thu Nov 1 12:40:15 EDT 2007
simplified examples template
--- a/tests/python/examples/aubionotes.py
+++ b/tests/python/examples/aubionotes.py
@@ -4,13 +4,14 @@
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 @@
""" 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
@@ -32,5 +32,10 @@
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."
+
+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()
--- a/tests/python/examples/aubioonset.py
+++ b/tests/python/examples/aubioonset.py
@@ -9,7 +9,6 @@
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 @@
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)
+for name in ["energy", "specdiff", "hfc", "complex", "phase", "kl", "mkl"]:
+ exec("class aubioonset_test_case_"+name+"(aubioonset_test_case):\n\
+ options = \" -O "+name+" \"")
-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()
+if __name__ == '__main__': unittest.main()
--- a/tests/python/examples/template.py
+++ b/tests/python/examples/template.py
@@ -6,9 +6,7 @@
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