]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
pyfec: trial-ize the unit tests, making sure to keep working if trial is unavailable
authorBrian Warner <warner@allmydata.com>
Sat, 7 Apr 2007 01:16:50 +0000 (18:16 -0700)
committerBrian Warner <warner@allmydata.com>
Sat, 7 Apr 2007 01:16:50 +0000 (18:16 -0700)
pyfec/fec/test/__init__.py [new file with mode: 0644]
pyfec/fec/test/test_pyfec.py
pyfec/setup.py

diff --git a/pyfec/fec/test/__init__.py b/pyfec/fec/test/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index e4a1a247ee268ea8f122752ba108a51cb2ef5910..d4f4fba9997904d478a07c9a728a5d742a7c21df 100644 (file)
@@ -91,12 +91,13 @@ def _test_random():
     ss = [ randstr(l/k) for x in range(k) ]
     _h(k, m, ss)
 
-def test_random():
+def test_random(noisy=True):
     for i in range(2**5):
         # sys.stdout.write(",")
         _test_random()
         # sys.stdout.write(".")
-    print "%d randomized tests pass." % (i+1)
+    if noisy:
+        print "%d randomized tests pass." % (i+1)
 
 def test_bad_args_enc():
     encer = fec.Encoder(2, 4)
@@ -137,7 +138,19 @@ def test_bad_args_dec():
         assert "Second argument was not a sequence" in str(e), e
     else:
         raise "Should have gotten TypeError for wrong type of second argument."
-    
+
+try:
+    from twisted.trial import unittest
+    class TestPyFec(unittest.TestCase):
+        def test_random(self):
+            test_random(False)
+        def test_bad_args_enc(self):
+            test_bad_args_enc()
+        def test_bad_args_dec(self):
+            test_bad_args_dec()
+except ImportError:
+    # trial is unavailable, oh well
+    pass
 
 if __name__ == "__main__":
     test_bad_args_dec()
index 8fbb755be94ff4da7d6074a231cce17439ce1bef..24ba55c77591f50ff4297de403a9f1e18dcb323f 100644 (file)
@@ -63,7 +63,7 @@ setup(name='pyfec',
       url='http://zooko.com/repos/pyfec',
       license='GNU GPL',
       platform='Any',
-      packages=['fec'],
+      packages=['fec', 'fec.test'],
       classifiers=trove_classifiers,
       ext_modules=[Extension('_fec', ['fec/fec.c', 'fec/_fecmodule.c',], extra_link_args=extra_link_args, extra_compile_args=extra_compile_args, undef_macros=undef_macros),],
       )