Index: tests/python/fft.py
===================================================================
--- tests/python/fft.py	(revision 2b3280abacda5f37518ee1579428fa9a4a908c68)
+++ tests/python/fft.py	(revision 038852adc8b117f21a4eb6f6996ffada072597da)
@@ -1,19 +1,18 @@
-import unittest
 import math
+
+from template import aubio_unit_template
 
 from aubio.aubiowrapper import *
 
-buf_size = 8092 
+buf_size = 1024
 channels = 4
 
-precision = 6
-
-class aubio_mfft_test_case(unittest.TestCase):
+class fft_unit(aubio_unit_template):
 
   def setUp(self):
-    self.o = new_aubio_mfft(buf_size, channels)
+    self.o = new_aubio_fft(buf_size, channels)
 
   def tearDown(self):
-    del_aubio_mfft(self.o)
+    del_aubio_fft(self.o)
 
   def test_create(self):
@@ -21,26 +20,26 @@
     pass
 
-  def test_aubio_mfft_do_zeroes(self):
-    """ test aubio_mfft_do on zeroes """
+  def test_do_zeroes(self):
+    """ test aubio_fft_do on zeroes """
     input    = new_fvec(buf_size, channels)
     fftgrain = new_cvec(buf_size, channels)
     for index in range(buf_size):
       for channel in range(channels):
-        self.assertEqual(0., fvec_read_sample(input, channel, index))
-    aubio_mfft_do(self.o, input, fftgrain)
+        self.assertCloseEnough(0., fvec_read_sample(input, channel, index))
+    aubio_fft_do(self.o, input, fftgrain)
     for index in range(buf_size/2+1):
       for channel in range(channels):
-        self.assertEqual(0., cvec_read_norm(fftgrain, channel, index))
+        self.assertCloseEnough(0., cvec_read_norm(fftgrain, channel, index))
     for index in range(buf_size/2+1):
       for channel in range(channels):
-        self.assertEqual(0., cvec_read_phas(fftgrain, channel, index))
+        self.assertCloseEnough(0., cvec_read_phas(fftgrain, channel, index))
     del fftgrain
     del input
 
-  def test_aubio_mfft_rdo_zeroes(self):
-    """ test aubio_mfft_rdo on zeroes """
+  def test_rdo_zeroes(self):
+    """ test aubio_fft_rdo on zeroes """
     fftgrain = new_cvec(buf_size, channels)
     output    = new_fvec(buf_size, channels)
-    aubio_mfft_rdo(self.o, fftgrain, output)
+    aubio_fft_rdo(self.o, fftgrain, output)
     # check output
     for index in range(buf_size):
@@ -50,6 +49,6 @@
     del output
 
-  def test_aubio_mfft_do_impulse(self):
-    """ test aubio_mfft_do with an impulse on one channel """
+  def test_do_impulse(self):
+    """ test aubio_fft_do with an impulse on one channel """
     input    = new_fvec(buf_size, channels)
     fftgrain = new_cvec(buf_size, channels)
@@ -57,8 +56,8 @@
     some_constant = 0.3412432456
     fvec_write_sample(input, some_constant, 0, 0)
-    aubio_mfft_do(self.o, input, fftgrain)
+    aubio_fft_do(self.o, input, fftgrain)
     # check norm
     for index in range(buf_size/2+1):
-      self.assertAlmostEqual(some_constant, cvec_read_norm(fftgrain, 0, index), precision)
+      self.assertCloseEnough(some_constant, cvec_read_norm(fftgrain, 0, index))
     for index in range(buf_size/2+1):
       for channel in range(1, channels):
@@ -71,6 +70,6 @@
     del input
 
-  def test_aubio_mfft_do_constant(self):
-    """ test aubio_mfft_do with a constant on one channel """
+  def test_do_constant(self):
+    """ test aubio_fft_do with a constant on one channel """
     input    = new_fvec(buf_size, channels)
     fftgrain = new_cvec(buf_size, channels)
@@ -79,5 +78,5 @@
     for index in range(1,buf_size):
       fvec_write_sample(input, some_constant, 0, index)
-    aubio_mfft_do(self.o, input, fftgrain)
+    aubio_fft_do(self.o, input, fftgrain)
     # check norm and phase == 0 in all other channels 
     for index in range(buf_size/2+1):
@@ -85,17 +84,17 @@
         self.assertEqual(0., cvec_read_norm(fftgrain, channel, index))
     # check norm and phase == 0 in first first and last bin of first channel
-    self.assertAlmostEqual((buf_size-1)*some_constant, cvec_read_norm(fftgrain, 0, 0), precision)
-    self.assertEqual(0., cvec_read_phas(fftgrain, 0, 0))
-    self.assertEqual(0., cvec_read_norm(fftgrain, 0, buf_size/2+1))
-    self.assertEqual(0., cvec_read_phas(fftgrain, 0, buf_size/2+1))
+    self.assertCloseEnough((buf_size-1)*some_constant, cvec_read_norm(fftgrain, 0, 0))
+    self.assertCloseEnough(0., cvec_read_phas(fftgrain, 0, 0))
+    self.assertCloseEnough(0., cvec_read_norm(fftgrain, 0, buf_size/2+1))
+    self.assertCloseEnough(0., cvec_read_phas(fftgrain, 0, buf_size/2+1))
     # check unwrap2pi(phas) ~= pi everywhere but in first bin
     for index in range(1,buf_size/2+1):
-       self.assertAlmostEqual ( math.pi, aubio_unwrap2pi(cvec_read_phas(fftgrain, 0, index)), precision)
-       self.assertAlmostEqual(some_constant, cvec_read_norm(fftgrain, 0, index), precision)
+       self.assertCloseEnough(math.pi, aubio_unwrap2pi(cvec_read_phas(fftgrain, 0, index)))
+       self.assertCloseEnough(some_constant, cvec_read_norm(fftgrain, 0, index))
     del fftgrain
     del input
 
-  def test_aubio_mfft_do_impulse_multichannel(self):
-    " test aubio_mfft_do on impulse two channels "
+  def test_do_impulse_multichannel(self):
+    " test aubio_fft_do on impulse two channels "
     input    = new_fvec(buf_size, channels)
     fftgrain = new_cvec(buf_size, channels)
@@ -103,5 +102,5 @@
     fvec_write_sample(input, 1., 0, 0)
     fvec_write_sample(input, 1., channels-1, 0)
-    aubio_mfft_do(self.o, input, fftgrain)
+    aubio_fft_do(self.o, input, fftgrain)
     # check the norm
     for index in range(buf_size/2+1):
@@ -119,19 +118,19 @@
     del input
 
-  def test_aubio_mfft_rdo_impulse(self):
-    """ test aubio_mfft_rdo on impulse """
+  def test_rdo_impulse(self):
+    """ test aubio_fft_rdo on impulse """
     fftgrain  = new_cvec(buf_size, channels)
     for channel in range(channels):
       cvec_write_norm(fftgrain, 1., channel, 0)
     output    = new_fvec(buf_size, channels)
-    aubio_mfft_rdo(self.o, fftgrain, output)
+    aubio_fft_rdo(self.o, fftgrain, output)
     for index in range(buf_size/2+1):
       for channel in range(channels):
-        self.assertAlmostEqual(fvec_read_sample(output, channel, index), 1./buf_size, precision)
+        self.assertCloseEnough(fvec_read_sample(output, channel, index), 1./buf_size)
     del fftgrain
     del output
 
-  def test_aubio_mfft_do_back_and_forth(self):
-    """ test aubio_mfft_rdo on a constant """
+  def test_do_back_and_forth(self):
+    """ test aubio_fft_rdo on a constant """
     input    = new_fvec(buf_size, channels)
     output   = new_fvec(buf_size, channels)
@@ -140,9 +139,9 @@
       for channel in range(channels):
         fvec_write_sample(input, 0.67, channel, index)
-    aubio_mfft_do(self.o, input, fftgrain)
-    aubio_mfft_rdo(self.o, fftgrain, output)
+    aubio_fft_do(self.o, input, fftgrain)
+    aubio_fft_rdo(self.o, fftgrain, output)
     for index in range(buf_size/2+1):
       for channel in range(channels):
-        self.assertAlmostEqual(fvec_read_sample(output, channel, index), 0.67, precision)
+        self.assertCloseEnough(0.67, fvec_read_sample(output, channel, index))
     del fftgrain
     del output
Index: tests/python/template.py
===================================================================
--- tests/python/template.py	(revision 038852adc8b117f21a4eb6f6996ffada072597da)
+++ tests/python/template.py	(revision 038852adc8b117f21a4eb6f6996ffada072597da)
@@ -0,0 +1,18 @@
+
+import unittest
+
+class aubio_unit_template(unittest.TestCase):
+  
+  def assertCloseEnough(self, first, second, places=5, msg=None):
+        """Fail if the two objects are unequal as determined by their
+           *relative* difference rounded to the given number of decimal places
+           (default 7) and comparing to zero.
+        """
+        if round(first, places) == 0:
+          if round(second-first, places) != 0:
+              raise self.failureException, \
+                    (msg or '%r != %r within %r places' % (first, second, places))
+        else:
+          if round((second-first)/first, places) != 0:
+              raise self.failureException, \
+                    (msg or '%r != %r within %r places' % (first, second, places))
