From 2ba535acb1f03fb7d1bdb57e4173d55661d300da Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 3 Dec 2009 21:19:54 -0500 Subject: 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 --- libbe/darcs.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'libbe/darcs.py') diff --git a/libbe/darcs.py b/libbe/darcs.py index 059452c..d94eaef 100644 --- a/libbe/darcs.py +++ b/libbe/darcs.py @@ -28,10 +28,12 @@ try: # import core module, Python >= 2.5 except ImportError: # look for non-core module from elementtree import ElementTree from xml.sax.saxutils import unescape -import doctest -import unittest +import libbe import vcs +if libbe.TESTING == True: + import doctest + import unittest def new(): @@ -183,7 +185,8 @@ class Darcs(vcs.VCS): except IndexError: return None -vcs.make_vcs_testcase_subclasses(Darcs, sys.modules[__name__]) +if libbe.TESTING == True: + vcs.make_vcs_testcase_subclasses(Darcs, sys.modules[__name__]) -unitsuite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__]) -suite = unittest.TestSuite([unitsuite, doctest.DocTestSuite()]) + unitsuite =unittest.TestLoader().loadTestsFromModule(sys.modules[__name__]) + suite = unittest.TestSuite([unitsuite, doctest.DocTestSuite()]) -- cgit