aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/beuuid.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-12-03 21:19:54 -0500
committerW. Trevor King <wking@drexel.edu>2009-12-03 21:19:54 -0500
commit2ba535acb1f03fb7d1bdb57e4173d55661d300da (patch)
tree935bca20ab4dd0122e45eb5b783bb96c52a3012b /libbe/beuuid.py
parent193bb7dc4fdb02ec1e79dcfacecdb4c352549a15 (diff)
downloadbugseverywhere-2ba535acb1f03fb7d1bdb57e4173d55661d300da.tar.gz
Added libbe.TESTING (defaults to False).
This flag allows us to skip unittest and testsuite declaration if we woln't need them. It speeds up simple be calls a suprising amount. With Testing=True (the old behavior): wking@thor:be.wtk$ time ./be > /dev/null real 0m0.393s user 0m0.340s sys 0m0.048s With TESTING=False (the new behavior): be.wtk$ time ./be > /dev/null real 0m0.216s user 0m0.152s sys 0m0.064s This adjustment was inspired by Jakub Wilk's Debian bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=559295
Diffstat (limited to 'libbe/beuuid.py')
-rw-r--r--libbe/beuuid.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/libbe/beuuid.py b/libbe/beuuid.py
index 260f3dc..a3a3b6c 100644
--- a/libbe/beuuid.py
+++ b/libbe/beuuid.py
@@ -20,7 +20,9 @@ Backwards compatibility support for Python 2.4. Once people give up
on 2.4 ;), the uuid call should be merged into bugdir.py
"""
-import unittest
+import libbe
+if libbe.TESTING == True:
+ import unittest
try:
@@ -56,9 +58,10 @@ except ImportError:
raise Exception, strerror
return output.rstrip('\n')
-class UUIDtestCase(unittest.TestCase):
- def testUUID_gen(self):
- id = uuid_gen()
- self.failUnless(len(id) == 36, "invalid UUID '%s'" % id)
+if libbe.TESTING == True:
+ class UUIDtestCase(unittest.TestCase):
+ def testUUID_gen(self):
+ id = uuid_gen()
+ self.failUnless(len(id) == 36, "invalid UUID '%s'" % id)
-suite = unittest.TestLoader().loadTestsFromTestCase(UUIDtestCase)
+ suite = unittest.TestLoader().loadTestsFromTestCase(UUIDtestCase)