Whitespace normalization.

This commit is contained in:
Tim Peters 2003-02-19 02:35:07 +00:00
parent f805cd2c1f
commit f2715e0764
26 changed files with 110 additions and 114 deletions

View file

@ -79,9 +79,9 @@ class Cmd:
def __init__(self, completekey='tab', stdin=None, stdout=None): def __init__(self, completekey='tab', stdin=None, stdout=None):
"""Instantiate a line-oriented interpreter framework. """Instantiate a line-oriented interpreter framework.
The optional argument 'completekey' is the readline name of a The optional argument 'completekey' is the readline name of a
completion key; it defaults to the Tab key. If completekey is completion key; it defaults to the Tab key. If completekey is
not None and the readline module is available, command completion not None and the readline module is available, command completion
is done automatically. The optional arguments stdin and stdout is done automatically. The optional arguments stdin and stdout
specify alternate input and output file objects; if not specified, specify alternate input and output file objects; if not specified,
sys.stdin and sys.stdout are used. sys.stdin and sys.stdout are used.

View file

@ -93,7 +93,7 @@ def copy(x):
raise Error("un(shallow)copyable object of type %s" % cls) raise Error("un(shallow)copyable object of type %s" % cls)
return _reconstruct(x, rv, 0) return _reconstruct(x, rv, 0)
_copy_dispatch = d = {} _copy_dispatch = d = {}

View file

@ -44,7 +44,7 @@ if 'posix' in _names:
except ImportError: except ImportError:
pass pass
import posixpath as path import posixpath as path
import posix import posix
__all__.extend(_get_exports_list(posix)) __all__.extend(_get_exports_list(posix))
del posix del posix
@ -58,7 +58,7 @@ elif 'nt' in _names:
except ImportError: except ImportError:
pass pass
import ntpath as path import ntpath as path
import nt import nt
__all__.extend(_get_exports_list(nt)) __all__.extend(_get_exports_list(nt))
del nt del nt
@ -75,7 +75,7 @@ elif 'os2' in _names:
import ntpath as path import ntpath as path
else: else:
import os2emxpath as path import os2emxpath as path
import os2 import os2
__all__.extend(_get_exports_list(os2)) __all__.extend(_get_exports_list(os2))
del os2 del os2
@ -89,7 +89,7 @@ elif 'mac' in _names:
except ImportError: except ImportError:
pass pass
import macpath as path import macpath as path
import mac import mac
__all__.extend(_get_exports_list(mac)) __all__.extend(_get_exports_list(mac))
del mac del mac
@ -104,7 +104,7 @@ elif 'ce' in _names:
pass pass
# We can use the standard Windows path. # We can use the standard Windows path.
import ntpath as path import ntpath as path
import ce import ce
__all__.extend(_get_exports_list(ce)) __all__.extend(_get_exports_list(ce))
del ce del ce
@ -118,7 +118,7 @@ elif 'riscos' in _names:
except ImportError: except ImportError:
pass pass
import riscospath as path import riscospath as path
import riscos import riscos
__all__.extend(_get_exports_list(riscos)) __all__.extend(_get_exports_list(riscos))
del riscos del riscos

View file

@ -553,7 +553,7 @@ tests = [
# escaping with \ as we know it # escaping with \ as we know it
('(?<!\\\):(.*?)(?<!\\\):', 'a:bc\\:de:f', SUCCEED, 'g1', 'bc\\:de' ), ('(?<!\\\):(.*?)(?<!\\\):', 'a:bc\\:de:f', SUCCEED, 'g1', 'bc\\:de' ),
# terminating with ' and escaping with ? as in edifact # terminating with ' and escaping with ? as in edifact
("(?<!\\?)'(.*?)(?<!\\?)'", "a'bc?'de'f", SUCCEED, 'g1', "bc?'de" ), ("(?<!\\?)'(.*?)(?<!\\?)'", "a'bc?'de'f", SUCCEED, 'g1', "bc?'de" ),
# Comments using the (?#...) syntax # Comments using the (?#...) syntax

View file

@ -933,7 +933,7 @@ class _ExpectedSkips:
if sys.platform != "win32": if sys.platform != "win32":
self.expected.add("test_winreg") self.expected.add("test_winreg")
self.expected.add("test_winsound") self.expected.add("test_winsound")
self.valid = True self.valid = True
def isvalid(self): def isvalid(self):

View file

@ -53,7 +53,7 @@ class TestAepack(unittest.TestCase):
packed = aepack.pack(o) packed = aepack.pack(o)
unpacked = aepack.unpack(packed) unpacked = aepack.unpack(packed)
self.assertEqual(repr(o), repr(unpacked)) self.assertEqual(repr(o), repr(unpacked))
def test_roundtrip_FSSpec(self): def test_roundtrip_FSSpec(self):
try: try:
import Carbon.File import Carbon.File
@ -72,9 +72,9 @@ class TestAepack(unittest.TestCase):
o = Carbon.File.FSSpec(os.curdir).NewAliasMinimal() o = Carbon.File.FSSpec(os.curdir).NewAliasMinimal()
packed = aepack.pack(o) packed = aepack.pack(o)
unpacked = aepack.unpack(packed) unpacked = aepack.unpack(packed)
self.assertEqual(o.FSResolveAlias(None)[0].as_pathname(), self.assertEqual(o.FSResolveAlias(None)[0].as_pathname(),
unpacked.FSResolveAlias(None)[0].as_pathname()) unpacked.FSResolveAlias(None)[0].as_pathname())
def test_main(): def test_main():
test_support.run_unittest(TestAepack) test_support.run_unittest(TestAepack)

View file

@ -214,4 +214,3 @@ def test_main(verbose=None):
if __name__ == "__main__": if __name__ == "__main__":
test_main(verbose=True) test_main(verbose=True)

View file

@ -352,10 +352,10 @@ class BuiltinTest(unittest.TestCase):
filter(identity, Squares(5)) filter(identity, Squares(5))
self.assertRaises(TypeError, filter) self.assertRaises(TypeError, filter)
class BadSeq(object): class BadSeq(object):
def __getitem__(self, index): def __getitem__(self, index):
if index<4: if index<4:
return 42 return 42
raise ValueError raise ValueError
self.assertRaises(ValueError, filter, lambda x: x, BadSeq()) self.assertRaises(ValueError, filter, lambda x: x, BadSeq())
def badfunc(): def badfunc():
pass pass
@ -441,13 +441,13 @@ class BuiltinTest(unittest.TestCase):
for (cls, inps) in inputs.iteritems(): for (cls, inps) in inputs.iteritems():
for (inp, exp) in inps.iteritems(): for (inp, exp) in inps.iteritems():
# make sure the output goes through __getitem__ # make sure the output goes through __getitem__
# even if func is None # even if func is None
self.assertEqual( self.assertEqual(
filter(funcs[0], cls(inp)), filter(funcs[0], cls(inp)),
filter(funcs[1], cls(inp)) filter(funcs[1], cls(inp))
) )
for func in funcs: for func in funcs:
outp = filter(func, cls(inp)) outp = filter(func, cls(inp))
self.assertEqual(outp, exp) self.assertEqual(outp, exp)
self.assert_(not isinstance(outp, cls)) self.assert_(not isinstance(outp, cls))
@ -1039,10 +1039,10 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, round) self.assertRaises(TypeError, round)
def test_setattr(self): def test_setattr(self):
setattr(sys, 'spam', 1) setattr(sys, 'spam', 1)
self.assertEqual(sys.spam, 1) self.assertEqual(sys.spam, 1)
self.assertRaises(TypeError, setattr, sys, 1, 'spam') self.assertRaises(TypeError, setattr, sys, 1, 'spam')
self.assertRaises(TypeError, setattr) self.assertRaises(TypeError, setattr)
def test_str(self): def test_str(self):
self.assertEqual(str(''), '') self.assertEqual(str(''), '')

View file

@ -11,7 +11,7 @@ class PosReturn:
oldpos = self.pos oldpos = self.pos
realpos = oldpos realpos = oldpos
if realpos<0: if realpos<0:
realpos = len(exc.object) + realpos realpos = len(exc.object) + realpos
# if we don't advance this time, terminate on the next call # if we don't advance this time, terminate on the next call
# otherwise we'd get an endless loop # otherwise we'd get an endless loop
if realpos <= exc.start: if realpos <= exc.start:
@ -532,7 +532,7 @@ class CodecCallbackTest(unittest.TestCase):
# and inline implementations # and inline implementations
v = (1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000) v = (1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000)
if sys.maxunicode>=100000: if sys.maxunicode>=100000:
v += (100000, 500000, 1000000) v += (100000, 500000, 1000000)
s = u"".join([unichr(x) for x in v]) s = u"".join([unichr(x) for x in v])
codecs.register_error("test.xmlcharrefreplace", codecs.xmlcharrefreplace_errors) codecs.register_error("test.xmlcharrefreplace", codecs.xmlcharrefreplace_errors)
for enc in ("ascii", "iso-8859-15"): for enc in ("ascii", "iso-8859-15"):

View file

@ -103,9 +103,9 @@ class TestTZInfo(unittest.TestCase):
orig = tzinfo.__new__(tzinfo) orig = tzinfo.__new__(tzinfo)
self.failUnless(type(orig) is tzinfo) self.failUnless(type(orig) is tzinfo)
for pickler, unpickler, proto in pickle_choices: for pickler, unpickler, proto in pickle_choices:
green = pickler.dumps(orig, proto) green = pickler.dumps(orig, proto)
derived = unpickler.loads(green) derived = unpickler.loads(green)
self.failUnless(type(derived) is tzinfo) self.failUnless(type(derived) is tzinfo)
def test_pickling_subclass(self): def test_pickling_subclass(self):
# Make sure we can pickle/unpickle an instance of a subclass. # Make sure we can pickle/unpickle an instance of a subclass.
@ -116,12 +116,12 @@ class TestTZInfo(unittest.TestCase):
self.assertEqual(orig.utcoffset(None), offset) self.assertEqual(orig.utcoffset(None), offset)
self.assertEqual(orig.tzname(None), 'cookie') self.assertEqual(orig.tzname(None), 'cookie')
for pickler, unpickler, proto in pickle_choices: for pickler, unpickler, proto in pickle_choices:
green = pickler.dumps(orig, proto) green = pickler.dumps(orig, proto)
derived = unpickler.loads(green) derived = unpickler.loads(green)
self.failUnless(isinstance(derived, tzinfo)) self.failUnless(isinstance(derived, tzinfo))
self.failUnless(type(derived) is PicklableFixedOffset) self.failUnless(type(derived) is PicklableFixedOffset)
self.assertEqual(derived.utcoffset(None), offset) self.assertEqual(derived.utcoffset(None), offset)
self.assertEqual(derived.tzname(None), 'cookie') self.assertEqual(derived.tzname(None), 'cookie')
############################################################################# #############################################################################
# Base clase for testing a particular aspect of timedelta, time, date and # Base clase for testing a particular aspect of timedelta, time, date and
@ -517,8 +517,8 @@ class TestDate(HarmlessMixedComparison):
fromord = self.theclass.fromordinal(n) fromord = self.theclass.fromordinal(n)
self.assertEqual(d, fromord) self.assertEqual(d, fromord)
if hasattr(fromord, "hour"): if hasattr(fromord, "hour"):
# if we're checking something fancier than a date, verify # if we're checking something fancier than a date, verify
# the extra fields have been zeroed out # the extra fields have been zeroed out
self.assertEqual(fromord.hour, 0) self.assertEqual(fromord.hour, 0)
self.assertEqual(fromord.minute, 0) self.assertEqual(fromord.minute, 0)
self.assertEqual(fromord.second, 0) self.assertEqual(fromord.second, 0)

View file

@ -1837,7 +1837,7 @@ def specials():
def __str__(self): def __str__(self):
if not self: if not self:
return 'EPS' return 'EPS'
return self return self
# sys.stdout needs to be the original to trigger the recursion bug # sys.stdout needs to be the original to trigger the recursion bug
import sys import sys

View file

@ -31,7 +31,7 @@ class LockTests(unittest.TestCase):
self.lock.release() self.lock.release()
self.failUnless(not self.lock.locked(), self.failUnless(not self.lock.locked(),
"Lock object did not release properly.") "Lock object did not release properly.")
def test_improper_release(self): def test_improper_release(self):
#Make sure release of an unlocked thread raises _thread.error #Make sure release of an unlocked thread raises _thread.error
self.failUnlessRaises(_thread.error, self.lock.release) self.failUnlessRaises(_thread.error, self.lock.release)
@ -58,7 +58,7 @@ class LockTests(unittest.TestCase):
#Make sure that an unconditional locking returns True. #Make sure that an unconditional locking returns True.
self.failUnless(self.lock.acquire(1) is True, self.failUnless(self.lock.acquire(1) is True,
"Unconditional locking did not return True.") "Unconditional locking did not return True.")
def test_uncond_acquire_blocking(self): def test_uncond_acquire_blocking(self):
#Make sure that unconditional acquiring of a locked lock blocks. #Make sure that unconditional acquiring of a locked lock blocks.
def delay_unlock(to_unlock, delay): def delay_unlock(to_unlock, delay):
@ -125,14 +125,14 @@ class ThreadTests(unittest.TestCase):
self.failUnless(result[0] and result[1], self.failUnless(result[0] and result[1],
"Argument passing for thread creation using both tuple" "Argument passing for thread creation using both tuple"
" and kwargs failed") " and kwargs failed")
def test_multi_creation(self): def test_multi_creation(self):
#Make sure multiple threads can be created. #Make sure multiple threads can be created.
def queue_mark(queue, delay): def queue_mark(queue, delay):
"""Wait for ``delay`` seconds and then put something into ``queue``""" """Wait for ``delay`` seconds and then put something into ``queue``"""
time.sleep(delay) time.sleep(delay)
queue.put(_thread.get_ident()) queue.put(_thread.get_ident())
thread_count = 5 thread_count = 5
delay = 1.5 delay = 1.5
testing_queue = Queue.Queue(thread_count) testing_queue = Queue.Queue(thread_count)
@ -147,7 +147,7 @@ class ThreadTests(unittest.TestCase):
if test_support.verbose: if test_support.verbose:
print 'done' print 'done'
self.failUnless(testing_queue.qsize() == thread_count, self.failUnless(testing_queue.qsize() == thread_count,
"Not all %s threads executed properly after %s sec." % "Not all %s threads executed properly after %s sec." %
(thread_count, delay)) (thread_count, delay))
def test_main(imported_module=None): def test_main(imported_module=None):

View file

@ -9,7 +9,7 @@ import time
class TestThread(_threading.Thread): class TestThread(_threading.Thread):
def run(self): def run(self):
global running global running
delay = random.random() * 2 delay = random.random() * 2
@ -54,7 +54,7 @@ def test_main():
global threads global threads
threads = [] threads = []
starttasks() starttasks()
if verbose: if verbose:

View file

@ -3,7 +3,7 @@ import locale
import sys import sys
if sys.platform == 'darwin': if sys.platform == 'darwin':
raise TestSkipped("Locale support on MacOSX is minimal and cannot be tested") raise TestSkipped("Locale support on MacOSX is minimal and cannot be tested")
oldlocale = locale.setlocale(locale.LC_NUMERIC) oldlocale = locale.setlocale(locale.LC_NUMERIC)
tloc = "en_US" tloc = "en_US"

View file

@ -22,11 +22,11 @@ class TestMacfs(unittest.TestCase):
def test_fsspec(self): def test_fsspec(self):
fss = macfs.FSSpec(test_support.TESTFN) fss = macfs.FSSpec(test_support.TESTFN)
self.assertEqual(os.path.realpath(test_support.TESTFN), fss.as_pathname()) self.assertEqual(os.path.realpath(test_support.TESTFN), fss.as_pathname())
def test_fsref(self): def test_fsref(self):
fsr = macfs.FSRef(test_support.TESTFN) fsr = macfs.FSRef(test_support.TESTFN)
self.assertEqual(os.path.realpath(test_support.TESTFN), fsr.as_pathname()) self.assertEqual(os.path.realpath(test_support.TESTFN), fsr.as_pathname())
def test_coercion(self): def test_coercion(self):
fss = macfs.FSSpec(test_support.TESTFN) fss = macfs.FSSpec(test_support.TESTFN)
fsr = macfs.FSRef(test_support.TESTFN) fsr = macfs.FSRef(test_support.TESTFN)
@ -34,7 +34,7 @@ class TestMacfs(unittest.TestCase):
fsr2 = fss.as_fsref() fsr2 = fss.as_fsref()
self.assertEqual(fss.as_pathname(), fss2.as_pathname()) self.assertEqual(fss.as_pathname(), fss2.as_pathname())
self.assertEqual(fsr.as_pathname(), fsr2.as_pathname()) self.assertEqual(fsr.as_pathname(), fsr2.as_pathname())
def test_dates(self): def test_dates(self):
import time import time
fss = macfs.FSSpec(test_support.TESTFN) fss = macfs.FSSpec(test_support.TESTFN)
@ -42,24 +42,24 @@ class TestMacfs(unittest.TestCase):
fss.SetDates(now, now-1, now-2) fss.SetDates(now, now-1, now-2)
dates = fss.GetDates() dates = fss.GetDates()
self.assertEqual(dates, (now, now-1, now-2)) self.assertEqual(dates, (now, now-1, now-2))
def test_ctor_type(self): def test_ctor_type(self):
fss = macfs.FSSpec(test_support.TESTFN) fss = macfs.FSSpec(test_support.TESTFN)
fss.SetCreatorType('Pyth', 'TEXT') fss.SetCreatorType('Pyth', 'TEXT')
filecr, filetp = fss.GetCreatorType() filecr, filetp = fss.GetCreatorType()
self.assertEqual((filecr, filetp), ('Pyth', 'TEXT')) self.assertEqual((filecr, filetp), ('Pyth', 'TEXT'))
def test_alias(self): def test_alias(self):
fss = macfs.FSSpec(test_support.TESTFN) fss = macfs.FSSpec(test_support.TESTFN)
alias = fss.NewAlias() alias = fss.NewAlias()
fss2, changed = alias.Resolve() fss2, changed = alias.Resolve()
self.assertEqual(changed, 0) self.assertEqual(changed, 0)
self.assertEqual(fss.as_pathname(), fss2.as_pathname()) self.assertEqual(fss.as_pathname(), fss2.as_pathname())
def test_fss_alias(self): def test_fss_alias(self):
fss = macfs.FSSpec(test_support.TESTFN) fss = macfs.FSSpec(test_support.TESTFN)
def test_main(): def test_main():
test_support.run_unittest(TestMacfs) test_support.run_unittest(TestMacfs)

View file

@ -29,7 +29,7 @@ class TestMacostools(unittest.TestCase):
os.unlink(TESTFN2) os.unlink(TESTFN2)
except: except:
pass pass
def compareData(self): def compareData(self):
fp = open(test_support.TESTFN, 'r') fp = open(test_support.TESTFN, 'r')
data1 = fp.read() data1 = fp.read()
@ -48,11 +48,11 @@ class TestMacostools(unittest.TestCase):
if data1 != data2: if data1 != data2:
return 'Resource forks differ' return 'Resource forks differ'
return '' return ''
def test_touched(self): def test_touched(self):
# This really only tests that nothing unforeseen happens. # This really only tests that nothing unforeseen happens.
macostools.touched(test_support.TESTFN) macostools.touched(test_support.TESTFN)
def test_copy(self): def test_copy(self):
try: try:
os.unlink(TESTFN2) os.unlink(TESTFN2)
@ -60,7 +60,7 @@ class TestMacostools(unittest.TestCase):
pass pass
macostools.copy(test_support.TESTFN, TESTFN2) macostools.copy(test_support.TESTFN, TESTFN2)
self.assertEqual(self.compareData(), '') self.assertEqual(self.compareData(), '')
def test_mkalias(self): def test_mkalias(self):
try: try:
os.unlink(TESTFN2) os.unlink(TESTFN2)
@ -69,7 +69,7 @@ class TestMacostools(unittest.TestCase):
macostools.mkalias(test_support.TESTFN, TESTFN2) macostools.mkalias(test_support.TESTFN, TESTFN2)
fss, _, _ = macfs.ResolveAliasFile(TESTFN2) fss, _, _ = macfs.ResolveAliasFile(TESTFN2)
self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN))
def test_mkalias_relative(self): def test_mkalias_relative(self):
try: try:
os.unlink(TESTFN2) os.unlink(TESTFN2)
@ -78,8 +78,8 @@ class TestMacostools(unittest.TestCase):
macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix) macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix)
fss, _, _ = macfs.ResolveAliasFile(TESTFN2) fss, _, _ = macfs.ResolveAliasFile(TESTFN2)
self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN)) self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN))
def test_main(): def test_main():
test_support.run_unittest(TestMacostools) test_support.run_unittest(TestMacostools)

View file

@ -370,7 +370,7 @@ class IllegalSyntaxTestCase(unittest.TestCase):
(266, (266,
(282, (1, 'foo'))), (4, ''))), (282, (1, 'foo'))), (4, ''))),
(4, ''), (4, ''),
(0, '')) (0, ''))
self.check_bad_tree(tree, "malformed global ast") self.check_bad_tree(tree, "malformed global ast")
def test_main(): def test_main():

View file

@ -82,4 +82,3 @@ for prec in range(100):
else: else:
#print result #print result
pass pass

View file

@ -127,18 +127,18 @@ class SysModuleTest(unittest.TestCase):
# testing sys.setprofile() is done in test_profile.py # testing sys.setprofile() is done in test_profile.py
def test_setcheckinterval(self): def test_setcheckinterval(self):
self.assertRaises(TypeError, sys.setcheckinterval) self.assertRaises(TypeError, sys.setcheckinterval)
sys.setcheckinterval(120) sys.setcheckinterval(120)
sys.setcheckinterval(100) sys.setcheckinterval(100)
def test_recursionlimit(self): def test_recursionlimit(self):
self.assertRaises(TypeError, sys.getrecursionlimit, 42) self.assertRaises(TypeError, sys.getrecursionlimit, 42)
oldlimit = sys.getrecursionlimit() oldlimit = sys.getrecursionlimit()
self.assertRaises(TypeError, sys.setrecursionlimit) self.assertRaises(TypeError, sys.setrecursionlimit)
self.assertRaises(ValueError, sys.setrecursionlimit, -42) self.assertRaises(ValueError, sys.setrecursionlimit, -42)
sys.setrecursionlimit(10000) sys.setrecursionlimit(10000)
self.assertEqual(sys.getrecursionlimit(), 10000) self.assertEqual(sys.getrecursionlimit(), 10000)
sys.setrecursionlimit(oldlimit) sys.setrecursionlimit(oldlimit)
def test_getwindowsversion(self): def test_getwindowsversion(self):
if hasattr(sys, "getwindowsversion"): if hasattr(sys, "getwindowsversion"):

View file

@ -21,6 +21,7 @@ def path(path):
return test_support.findfile(path) return test_support.findfile(path)
testtar = path("testtar.tar") testtar = path("testtar.tar")
print testtar
tempdir = path("testtar.dir") tempdir = path("testtar.dir")
tempname = path("testtar.tmp") tempname = path("testtar.tmp")
membercount = 10 membercount = 10

View file

@ -258,4 +258,3 @@ def test_main():
if __name__ == "__main__": if __name__ == "__main__":
test_main() test_main()

View file

@ -39,7 +39,7 @@ def test_main():
for test in (DumpCPickle_LoadPickle, for test in (DumpCPickle_LoadPickle,
DumpPickle_LoadCPickle, DumpPickle_LoadCPickle,
): ):
suite.addTest(unittest.makeSuite(test)) suite.addTest(unittest.makeSuite(test))
test_support.run_suite(suite) test_support.run_suite(suite)
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -16,11 +16,11 @@ import zipimport
def make_pyc(co, mtime): def make_pyc(co, mtime):
data = marshal.dumps(co) data = marshal.dumps(co)
if type(mtime) is type(0.0): if type(mtime) is type(0.0):
# Mac mtimes need a bit of special casing # Mac mtimes need a bit of special casing
if mtime < 0x7fffffff: if mtime < 0x7fffffff:
mtime = int(mtime) mtime = int(mtime)
else: else:
mtime = int(-0x100000000L + long(mtime)) mtime = int(-0x100000000L + long(mtime))
pyc = imp.get_magic() + struct.pack("<i", int(mtime)) + data pyc = imp.get_magic() + struct.pack("<i", int(mtime)) + data
return pyc return pyc

View file

@ -103,7 +103,7 @@ class CompressTestCase(unittest.TestCase):
self.failUnless(last > len(data), "compress level 0 always expands") self.failUnless(last > len(data), "compress level 0 always expands")
for level in range(10): for level in range(10):
length = len(zlib.compress(data, level)) length = len(zlib.compress(data, level))
self.failUnless(length <= last, self.failUnless(length <= last,
'compress level %d more effective than %d!' % ( 'compress level %d more effective than %d!' % (
level-1, level)) level-1, level))
last = length last = length
@ -506,4 +506,3 @@ if False:
su = ut.TestSuite() su = ut.TestSuite()
su.addTest(ut.makeSuite(tz.CompressTestCase)) su.addTest(ut.makeSuite(tz.CompressTestCase))
ts.run_suite(su) ts.run_suite(su)

View file

@ -1,5 +1,5 @@
# Tests for the 'tokenize' module. # Tests for the 'tokenize' module.
# Large bits stolen from test_grammar.py. # Large bits stolen from test_grammar.py.
# Comments # Comments
"#" "#"
@ -129,17 +129,17 @@ bar \\ baz
if 1: if 1:
x = 2 x = 2
if 1: if 1:
x = 2 x = 2
if 1: if 1:
while 0: while 0:
if 0: if 0:
x = 2 x = 2
x = 2 x = 2
if 0: if 0:
if 2: if 2:
while 0: while 0:
if 1: if 1:
x = 2 x = 2
# Operators # Operators
@ -172,4 +172,3 @@ x = -1*1/1 + 1*1 - ---1*1
# selector # selector
import sys, time import sys, time
x = sys.modules['time'].time() x = sys.modules['time'].time()

View file

@ -146,7 +146,7 @@ class Ignore:
class CoverageResults: class CoverageResults:
def __init__(self, counts=None, calledfuncs=None, infile=None, def __init__(self, counts=None, calledfuncs=None, infile=None,
outfile=None): outfile=None):
self.counts = counts self.counts = counts
if self.counts is None: if self.counts is None:
self.counts = {} self.counts = {}
@ -164,7 +164,7 @@ class CoverageResults:
if type(thingie) is types.DictType: if type(thingie) is types.DictType:
# backwards compatibility for old trace.py after # backwards compatibility for old trace.py after
# Zooko touched it but before calledfuncs --Zooko # Zooko touched it but before calledfuncs --Zooko
# 2001-10-24 # 2001-10-24
self.update(self.__class__(thingie)) self.update(self.__class__(thingie))
elif type(thingie) is types.TupleType and len(thingie) == 2: elif type(thingie) is types.TupleType and len(thingie) == 2:
counts, calledfuncs = thingie counts, calledfuncs = thingie
@ -173,7 +173,7 @@ class CoverageResults:
pass pass
except pickle.UnpicklingError: except pickle.UnpicklingError:
# backwards compatibility for old trace.py before # backwards compatibility for old trace.py before
# Zooko touched it --Zooko 2001-10-24 # Zooko touched it --Zooko 2001-10-24
self.update(self.__class__(marshal.load(open(self.infile)))) self.update(self.__class__(marshal.load(open(self.infile))))
def update(self, other): def update(self, other):
@ -187,7 +187,7 @@ class CoverageResults:
if key != 'calledfuncs': if key != 'calledfuncs':
# backwards compatibility for abortive attempt to # backwards compatibility for abortive attempt to
# stuff calledfuncs into self.counts, by Zooko # stuff calledfuncs into self.counts, by Zooko
# --Zooko 2001-10-24 # --Zooko 2001-10-24
counts[key] = counts.get(key, 0) + other_counts[key] counts[key] = counts.get(key, 0) + other_counts[key]
for key in other_calledfuncs.keys(): for key in other_calledfuncs.keys():
@ -406,18 +406,18 @@ class Trace:
ignoredirs=(), infile=None, outfile=None): ignoredirs=(), infile=None, outfile=None):
""" """
@param count true iff it should count number of times each @param count true iff it should count number of times each
line is executed line is executed
@param trace true iff it should print out each line that is @param trace true iff it should print out each line that is
being counted being counted
@param countfuncs true iff it should just output a list of @param countfuncs true iff it should just output a list of
(filename, modulename, funcname,) for functions (filename, modulename, funcname,) for functions
that were called at least once; This overrides that were called at least once; This overrides
`count' and `trace' `count' and `trace'
@param ignoremods a list of the names of modules to ignore @param ignoremods a list of the names of modules to ignore
@param ignoredirs a list of the names of directories to ignore @param ignoredirs a list of the names of directories to ignore
all of the (recursive) contents of all of the (recursive) contents of
@param infile file from which to read stored counts to be @param infile file from which to read stored counts to be
added into the results added into the results
@param outfile file in which to write the results @param outfile file in which to write the results
""" """
self.infile = infile self.infile = infile
@ -516,19 +516,19 @@ class Trace:
# XXX I wish inspect offered me an optimized # XXX I wish inspect offered me an optimized
# `getfilename(frame)' to use in place of the presumably # `getfilename(frame)' to use in place of the presumably
# heavier `getframeinfo()'. --Zooko 2001-10-14 # heavier `getframeinfo()'. --Zooko 2001-10-14
filename, lineno, funcname, context, lineindex = \ filename, lineno, funcname, context, lineindex = \
inspect.getframeinfo(frame, 1) inspect.getframeinfo(frame, 1)
key = filename, lineno key = filename, lineno
self.counts[key] = self.counts.get(key, 0) + 1 self.counts[key] = self.counts.get(key, 0) + 1
# XXX not convinced that this memoizing is a performance # XXX not convinced that this memoizing is a performance
# win -- I don't know enough about Python guts to tell. # win -- I don't know enough about Python guts to tell.
# --Zooko 2001-10-14 # --Zooko 2001-10-14
bname = self.pathtobasename.get(filename) bname = self.pathtobasename.get(filename)
if bname is None: if bname is None:
# Using setdefault faster than two separate lines? # Using setdefault faster than two separate lines?
# --Zooko 2001-10-14 # --Zooko 2001-10-14
bname = self.pathtobasename.setdefault(filename, bname = self.pathtobasename.setdefault(filename,
@ -553,7 +553,7 @@ class Trace:
# heavier `getframeinfo()'. --Zooko 2001-10-14 # heavier `getframeinfo()'. --Zooko 2001-10-14
filename, lineno, funcname, context, lineindex = \ filename, lineno, funcname, context, lineindex = \
inspect.getframeinfo(frame) inspect.getframeinfo(frame)
# XXX not convinced that this memoizing is a performance # XXX not convinced that this memoizing is a performance
# win -- I don't know enough about Python guts to tell. # win -- I don't know enough about Python guts to tell.
# --Zooko 2001-10-14 # --Zooko 2001-10-14