Skip to content

Commit cf70223

Browse files
author
Richard Jones
committed
make this run under py2.1
1 parent ca9446a commit cf70223

File tree

1 file changed

+42
-49
lines changed

1 file changed

+42
-49
lines changed

run_tests.py

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,17 @@ class ImmediateTestResult(unittest._TextTestResult):
176176
__super_startTest = unittest._TextTestResult.startTest
177177
__super_printErrors = unittest._TextTestResult.printErrors
178178

179-
def __init__(self, stream, descriptions, verbosity, debug=False,
180-
count=None, progress=False):
179+
def __init__(self, stream, descriptions, verbosity, debug=0,
180+
count=None, progress=0):
181181
self.__super_init(stream, descriptions, verbosity)
182182
self._debug = debug
183183
self._progress = progress
184-
self._progressWithNames = False
184+
self._progressWithNames = 0
185185
self._count = count
186186
self._testtimes = {}
187187
if progress and verbosity == 1:
188-
self.dots = False
189-
self._progressWithNames = True
188+
self.dots = 0
189+
self._progressWithNames = 1
190190
self._lastWidth = 0
191191
self._maxWidth = 80
192192
try:
@@ -344,9 +344,9 @@ def __init__(self, build, build_inplace, libdir=None):
344344
if self.inplace is None:
345345
# Need to figure it out
346346
if os.path.isdir(os.path.join("build", "lib.%s" % PLAT_SPEC)):
347-
self.inplace = False
347+
self.inplace = 0
348348
else:
349-
self.inplace = True
349+
self.inplace = 1
350350
# Calculate which directories we're going to add to sys.path, and cd
351351
# to the appropriate working directory
352352
org_cwd = os.getcwd()
@@ -381,7 +381,7 @@ def __init__(self, build, build_inplace, libdir=None):
381381

382382
def match(rx, s):
383383
if not rx:
384-
return True
384+
return 1
385385
if rx[0] == "!":
386386
return re.search(rx[1:], s) is None
387387
else:
@@ -625,20 +625,21 @@ def main(module_filter, test_filter, libdir):
625625
global pathinit
626626
pathinit = PathInit(build, build_inplace, libdir)
627627

628-
# Initialize the logging module.
628+
# No logging module in py 2.1
629+
# # Initialize the logging module.
629630

630-
import logging.config
631-
logging.basicConfig()
631+
# import logging.config
632+
# logging.basicConfig()
632633

633-
level = os.getenv("LOGGING")
634-
if level:
635-
level = int(level)
636-
else:
637-
level = logging.CRITICAL
638-
logging.root.setLevel(level)
634+
# level = os.getenv("LOGGING")
635+
# if level:
636+
# level = int(level)
637+
# else:
638+
# level = logging.CRITICAL
639+
# logging.root.setLevel(level)
639640

640-
if os.path.exists(logini):
641-
logging.config.fileConfig(logini)
641+
# if os.path.exists(logini):
642+
# logging.config.fileConfig(logini)
642643

643644
files = find_tests(module_filter)
644645
files.sort()
@@ -649,7 +650,7 @@ def main(module_filter, test_filter, libdir):
649650
if REFCOUNT:
650651
rc = sys.gettotalrefcount()
651652
track = TrackRefs()
652-
while True:
653+
while 1:
653654
runner(files, test_filter, debug)
654655
gc.collect()
655656
if gc.garbage:
@@ -692,24 +693,24 @@ def process_args(argv=None):
692693
module_filter = None
693694
test_filter = None
694695
VERBOSE = 1
695-
LOOP = False
696-
GUI = False
697-
TRACE = False
698-
REFCOUNT = False
699-
debug = False # Don't collect test results; simply let tests crash
700-
debugger = False
701-
build = False
702-
build_inplace = False
696+
LOOP = 0
697+
GUI = 0
698+
TRACE = 0
699+
REFCOUNT = 0
700+
debug = 0 # Don't collect test results; simply let tests crash
701+
debugger = 0
702+
build = 0
703+
build_inplace = 0
703704
gcthresh = None
704705
gcdebug = 0
705706
gcflags = []
706707
level = 1
707708
libdir = '.'
708-
progress = False
709+
progress = 0
709710
timesfn = None
710711
timetests = 0
711712
keepStaleBytecode = 0
712-
functional = False
713+
functional = 0
713714
test_dir = None
714715

715716
try:
@@ -728,21 +729,21 @@ def process_args(argv=None):
728729
level = 0
729730
os.environ["COMPLAIN_IF_TESTS_MISSED"]='1'
730731
elif k in ("-b", "--build"):
731-
build = True
732+
build = 1
732733
elif k == "-B":
733-
build = build_inplace = True
734+
build = build_inplace = 1
734735
elif k == "-c":
735736
# make sure you have a recent version of pychecker
736737
if not os.environ.get("PYCHECKER"):
737738
os.environ["PYCHECKER"] = "-q"
738739
import pychecker.checker
739740
elif k == "-d":
740-
debug = True
741+
debug = 1
741742
elif k == "-D":
742-
debug = True
743-
debugger = True
743+
debug = 1
744+
debugger = 1
744745
elif k == "-f":
745-
functional = True
746+
functional = 1
746747
elif k in ("-h", "--help"):
747748
print __doc__
748749
sys.exit(0)
@@ -762,14 +763,14 @@ def process_args(argv=None):
762763
elif k == "-m":
763764
GUI = "minimal"
764765
elif k == "-p":
765-
progress = True
766+
progress = 1
766767
elif k == "-r":
767768
if hasattr(sys, "gettotalrefcount"):
768-
REFCOUNT = True
769+
REFCOUNT = 1
769770
else:
770771
print "-r ignored, because it needs a debug build of Python"
771772
elif k == "-T":
772-
TRACE = True
773+
TRACE = 1
773774
elif k == "-t":
774775
if not timetests:
775776
timetests = 50
@@ -786,14 +787,6 @@ def process_args(argv=None):
786787
elif k == '--dir':
787788
test_dir = v
788789

789-
if sys.version_info < ( 2,2,3 ):
790-
print """\
791-
ERROR: Your python version is not supported by Zope3.
792-
Zope3 needs either Python2.3 or Python2.2.3 or greater.
793-
In particular, Zope3 on Python2.2.2 is a recipe for
794-
pain. You are running:""" + sys.version
795-
sys.exit(1)
796-
797790
if gcthresh is not None:
798791
if gcthresh == 0:
799792
gc.disable()
@@ -864,7 +857,7 @@ def process_args(argv=None):
864857
ignoremods = ["os", "posixpath", "stat"]
865858
tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
866859
ignoremods=ignoremods,
867-
trace=False, count=True)
860+
trace=0, count=1)
868861

869862
tracer.runctx("main(module_filter, test_filter, libdir)",
870863
globals=globals(), locals=vars())
@@ -875,7 +868,7 @@ def process_args(argv=None):
875868
cPickle.dump(r, f)
876869
f.close()
877870
print path
878-
r.write_results(show_missing=True, summary=True, coverdir=coverdir)
871+
r.write_results(show_missing=1, summary=1, coverdir=coverdir)
879872
else:
880873
bad = main(module_filter, test_filter, libdir)
881874
if bad:

0 commit comments

Comments
 (0)