From 176c24634bd3a371d6372d08a00b41a5ec7cf3b4 Mon Sep 17 00:00:00 2001
From: Tobias Schmidt <tobias.schmidt@unibas.ch>
Date: Fri, 20 Jan 2012 10:35:54 +0100
Subject: [PATCH] use new RunTest function in all python unittests

---
 modules/base/tests/test_log.py                     | 6 ++----
 modules/base/tests/test_stutil.py                  | 6 ++----
 modules/base/tests/test_table.py                   | 8 +++-----
 modules/bindings/tests/test_blast.py               | 6 ++----
 modules/bindings/tests/test_clustalw.py            | 6 ++----
 modules/bindings/tests/test_msms.py                | 6 ++----
 modules/conop/tests/test_cleanup.py                | 6 ++++--
 modules/conop/tests/test_compound.py               | 4 ++--
 modules/conop/tests/test_nonstandard.py            | 4 ++--
 modules/geom/tests/test_geom.py                    | 3 ++-
 modules/gfx/tests/test_gfx.py                      | 3 ++-
 modules/io/tests/test_io_mmcif.py                  | 3 ++-
 modules/io/tests/test_io_pdb.py                    | 3 ++-
 modules/mol/alg/tests/test_convenient_superpose.py | 3 ++-
 modules/seq/alg/tests/test_aligntoseqres.py        | 6 ++----
 modules/seq/alg/tests/test_global_align.py         | 6 ++----
 modules/seq/alg/tests/test_local_align.py          | 6 ++----
 modules/seq/alg/tests/test_renumber.py             | 6 ++----
 modules/seq/alg/tests/test_weight_matrix.py        | 6 ++----
 modules/seq/base/tests/test_seq.py                 | 6 ++++--
 20 files changed, 45 insertions(+), 58 deletions(-)

diff --git a/modules/base/tests/test_log.py b/modules/base/tests/test_log.py
index 9b6952c91..cec9378ed 100644
--- a/modules/base/tests/test_log.py
+++ b/modules/base/tests/test_log.py
@@ -39,7 +39,5 @@ class TestLog(unittest.TestCase):
     self.assertEqual(ls.severity, 1)
     ost.PopLogSink()
 if __name__ == "__main__":
-  try:
-    unittest.main()
-  except Exception, e:
-    print e
\ No newline at end of file
+  from ost import testutils
+  testutils.RunTests()
\ No newline at end of file
diff --git a/modules/base/tests/test_stutil.py b/modules/base/tests/test_stutil.py
index 6cc4570b5..7d5b9f98f 100644
--- a/modules/base/tests/test_stutil.py
+++ b/modules/base/tests/test_stutil.py
@@ -86,7 +86,5 @@ class TestStUtils(unittest.TestCase):
            (stutil.Correl(self.data3, self.data2), self.correl2)
 
 if __name__ == "__main__":
-  try:
-    unittest.main()
-  except Exception, e:
-    print e
\ No newline at end of file
+  from ost import testutils
+  testutils.RunTests()
\ No newline at end of file
diff --git a/modules/base/tests/test_table.py b/modules/base/tests/test_table.py
index f2d028067..270780a16 100644
--- a/modules/base/tests/test_table.py
+++ b/modules/base/tests/test_table.py
@@ -40,7 +40,7 @@ except ImportError:
   print "Could not find python imagine library: ignoring some table class unit tests"
 
 class TestTable(unittest.TestCase):
-  
+
   def setUp(self):
     ost.PushVerbosityLevel(3)
 
@@ -1289,7 +1289,5 @@ class TestTable(unittest.TestCase):
     self.assertAlmostEquals(tab.SpearmanCorrel('second','third'), -0.316227766)
     
 if __name__ == "__main__":
-  try:
-    unittest.main()
-  except Exception, e:
-    print e
+  from ost import testutils
+  testutils.RunTests()
diff --git a/modules/bindings/tests/test_blast.py b/modules/bindings/tests/test_blast.py
index e8e151a4e..8b4215faa 100644
--- a/modules/bindings/tests/test_blast.py
+++ b/modules/bindings/tests/test_blast.py
@@ -44,7 +44,5 @@ if __name__ == "__main__":
   except(settings.FileNotFound):
     print "Could not find blastall executable: ignoring unit tests"
     sys.exit(0)
-  try:
-    unittest.main()
-  except Exception, e:
-    print e
+  from ost import testutils
+  testutils.RunTests()
diff --git a/modules/bindings/tests/test_clustalw.py b/modules/bindings/tests/test_clustalw.py
index 0fdb040db..fa5a5e6b5 100644
--- a/modules/bindings/tests/test_clustalw.py
+++ b/modules/bindings/tests/test_clustalw.py
@@ -68,7 +68,5 @@ if __name__ == "__main__":
   except(settings.FileNotFound):
     print "Could not find clustalw executable: ignoring unit tests"
     sys.exit(0)
-  try:
-    unittest.main()
-  except Exception, e:
-    print e
+  from ost import testutils
+  testutils.RunTests()
diff --git a/modules/bindings/tests/test_msms.py b/modules/bindings/tests/test_msms.py
index 054a63cff..9041f94fa 100755
--- a/modules/bindings/tests/test_msms.py
+++ b/modules/bindings/tests/test_msms.py
@@ -42,7 +42,5 @@ if __name__ == "__main__":
   version = msms.GetVersion(msms_exe=None, msms_env='MSMSSERVER')
   if version!=VERSION_REQUIRED:
     print "MSMS version (%s) does not match required version %s: ignoring unit tests"%(version, VERSION_REQUIRED)
-  try:
-    unittest.main()
-  except Exception, e:
-    print e
+  from ost import testutils
+  testutils.RunTests()
diff --git a/modules/conop/tests/test_cleanup.py b/modules/conop/tests/test_cleanup.py
index ee6ab57ca..1dc280f4f 100644
--- a/modules/conop/tests/test_cleanup.py
+++ b/modules/conop/tests/test_cleanup.py
@@ -158,5 +158,7 @@ class TestCleanUp(unittest.TestCase):
 if not hasattr(conop.GetBuilder(), 'compound_lib'):
   print 'Default builder without compound lib. Ignoring test_cleanup.py tests'
   sys.exit()
-suite = unittest.TestLoader().loadTestsFromTestCase(TestCleanUp)
-unittest.TextTestRunner().run(suite)
+
+if __name__== '__main__':
+  from ost import testutils
+  testutils.RunTests()
diff --git a/modules/conop/tests/test_compound.py b/modules/conop/tests/test_compound.py
index 2c57bce75..a215a78f7 100644
--- a/modules/conop/tests/test_compound.py
+++ b/modules/conop/tests/test_compound.py
@@ -26,6 +26,6 @@ if __name__=='__main__':
   if not hasattr(builder, 'compound_lib'):
     print 'default builder does not use compound library. ignoring unit tests'
   else:
-    suite = unittest.TestLoader().loadTestsFromTestCase(TestCompound)
-    unittest.TextTestRunner().run(suite)
+    from ost import testutils
+    testutils.RunTests()
 
diff --git a/modules/conop/tests/test_nonstandard.py b/modules/conop/tests/test_nonstandard.py
index 57de3864e..170749c6e 100644
--- a/modules/conop/tests/test_nonstandard.py
+++ b/modules/conop/tests/test_nonstandard.py
@@ -121,7 +121,7 @@ if __name__ == "__main__":
   if not hasattr(builder, 'compound_lib'):
     print 'default builder does not use compound library. ignoring unit tests'
   else:
-    suite = unittest.TestLoader().loadTestsFromTestCase(TestNonStandard)
-    unittest.TextTestRunner().run(suite)
+    from ost import testutils
+    testutils.RunTests()
 
 
diff --git a/modules/geom/tests/test_geom.py b/modules/geom/tests/test_geom.py
index e25081bf1..f563add91 100644
--- a/modules/geom/tests/test_geom.py
+++ b/modules/geom/tests/test_geom.py
@@ -80,5 +80,6 @@ class TestGeom(unittest.TestCase):
                       13,14,15,16])
     
 if __name__== '__main__':
-  unittest.main()
+  from ost import testutils
+  testutils.RunTests()
 
diff --git a/modules/gfx/tests/test_gfx.py b/modules/gfx/tests/test_gfx.py
index 0ddeeab7e..ffca3b507 100644
--- a/modules/gfx/tests/test_gfx.py
+++ b/modules/gfx/tests/test_gfx.py
@@ -132,5 +132,6 @@ class TestGfx(unittest.TestCase):
                  
 
 if __name__== '__main__':
-  unittest.main()
+  from ost import testutils
+  testutils.RunTests()
 
diff --git a/modules/io/tests/test_io_mmcif.py b/modules/io/tests/test_io_mmcif.py
index 82c0be2e8..2a137b13b 100644
--- a/modules/io/tests/test_io_mmcif.py
+++ b/modules/io/tests/test_io_mmcif.py
@@ -155,6 +155,7 @@ class TestMMCifInfo(unittest.TestCase):
     self.assertEquals(i.GetObsoleteInfo().GetReplacedPDBID(), '2BAR')
 
 if __name__== '__main__':
-    unittest.main()
+  from ost import testutils
+  testutils.RunTests()
 
 
diff --git a/modules/io/tests/test_io_pdb.py b/modules/io/tests/test_io_pdb.py
index c8bb3902d..873a91e15 100644
--- a/modules/io/tests/test_io_pdb.py
+++ b/modules/io/tests/test_io_pdb.py
@@ -12,6 +12,7 @@ class TestPDB(unittest.TestCase):
     self.assertEquals(ch.GetIntProp("mol_id"), 1)
 
 if __name__== '__main__':
-    unittest.main()
+  from ost import testutils
+  testutils.RunTests()
 
 
diff --git a/modules/mol/alg/tests/test_convenient_superpose.py b/modules/mol/alg/tests/test_convenient_superpose.py
index 7e03558c0..eb4331ca3 100644
--- a/modules/mol/alg/tests/test_convenient_superpose.py
+++ b/modules/mol/alg/tests/test_convenient_superpose.py
@@ -193,4 +193,5 @@ class TestConvenientSuperpose(unittest.TestCase):
     self.assertEqualAtomOrder(view1, view2)
 
 if __name__ == "__main__":
-  unittest.main()
+  from ost import testutils
+  testutils.RunTests()
diff --git a/modules/seq/alg/tests/test_aligntoseqres.py b/modules/seq/alg/tests/test_aligntoseqres.py
index f31ff9ffa..0f4b8ceaa 100644
--- a/modules/seq/alg/tests/test_aligntoseqres.py
+++ b/modules/seq/alg/tests/test_aligntoseqres.py
@@ -68,7 +68,5 @@ class TestAlignToSeqRes(unittest.TestCase):
     self.assertEqual(seq.alg.ValidateSEQRESAlignment(seqres_aln, chain), False)
 
 if __name__ == "__main__":
-  try:
-    unittest.main()
-  except Exception, e:
-    print e
+  from ost import testutils
+  testutils.RunTests()
diff --git a/modules/seq/alg/tests/test_global_align.py b/modules/seq/alg/tests/test_global_align.py
index aed51741b..b23503cd0 100644
--- a/modules/seq/alg/tests/test_global_align.py
+++ b/modules/seq/alg/tests/test_global_align.py
@@ -44,7 +44,5 @@ class TestGlobalAlign(unittest.TestCase):
     self.assertEqual(alns[0].sequences[1].offset, 0)
 
 if __name__ == "__main__":
-  try:
-    unittest.main()
-  except Exception, e:
-    print e
+  from ost import testutils
+  testutils.RunTests()
diff --git a/modules/seq/alg/tests/test_local_align.py b/modules/seq/alg/tests/test_local_align.py
index ff6872f9d..47f78f686 100644
--- a/modules/seq/alg/tests/test_local_align.py
+++ b/modules/seq/alg/tests/test_local_align.py
@@ -43,7 +43,5 @@ class TestLocalAlign(unittest.TestCase):
     self.assertEqual(alns[0].sequences[1].offset, 2)
 
 if __name__ == "__main__":
-  try:
-    unittest.main()
-  except Exception, e:
-    print e
+  from ost import testutils
+  testutils.RunTests()
diff --git a/modules/seq/alg/tests/test_renumber.py b/modules/seq/alg/tests/test_renumber.py
index 76a9bf1d1..51e4727d3 100644
--- a/modules/seq/alg/tests/test_renumber.py
+++ b/modules/seq/alg/tests/test_renumber.py
@@ -118,7 +118,5 @@ if __name__ == "__main__":
   except(settings.FileNotFound):
     print "Could not find clustalw executable: ignoring unit tests"
     sys.exit(0)  
-  try:
-    unittest.main()
-  except Exception, e:
-    print e
+  from ost import testutils
+  testutils.RunTests()
diff --git a/modules/seq/alg/tests/test_weight_matrix.py b/modules/seq/alg/tests/test_weight_matrix.py
index 7d85996fb..91cf83037 100644
--- a/modules/seq/alg/tests/test_weight_matrix.py
+++ b/modules/seq/alg/tests/test_weight_matrix.py
@@ -39,7 +39,5 @@ class TestWeightMatrix(unittest.TestCase):
     self.assertEqual(mat.GetWeight('?', 'E'), 0)
 
 if __name__ == "__main__":
-  try:
-    unittest.main()
-  except Exception, e:
-    print e
+  from ost import testutils
+  testutils.RunTests()
diff --git a/modules/seq/base/tests/test_seq.py b/modules/seq/base/tests/test_seq.py
index 7cc73a5ce..bfd80d7bf 100644
--- a/modules/seq/base/tests/test_seq.py
+++ b/modules/seq/base/tests/test_seq.py
@@ -174,6 +174,8 @@ class TestSeq(unittest.TestCase):
     string_b=''.join([r.one_letter_code for r in b.residues])
     self.assertEqual(string_a, 'BDFH')
     self.assertEqual(string_b, 'BDFH')
-suite = unittest.TestLoader().loadTestsFromTestCase(TestSeq)
-unittest.TextTestRunner().run(suite)
+
+if __name__== '__main__':
+  from ost import testutils
+  testutils.RunTests()
 
-- 
GitLab