rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
def create_exe (self, arcname): | def create_exe (self, arcname, fullname): | def create_exe (self, arcname): import struct, zlib | d632280482e5e5e66cebc993062f0fd1e60755b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d632280482e5e5e66cebc993062f0fd1e60755b5/bdist_wininst.py |
installer_name = "%s.win32.exe" % self.distribution.get_fullname() | installer_name = os.path.join(self.dist_dir, "%s.win32.exe" % fullname) | def create_exe (self, arcname): import struct, zlib | d632280482e5e5e66cebc993062f0fd1e60755b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d632280482e5e5e66cebc993062f0fd1e60755b5/bdist_wininst.py |
dir = os.path.join(self.root, dir[1:]) | dir = change_root(self.root, dir) | def run (self): self.mkpath(self.install_dir) for f in self.data_files: if type(f) == StringType: # its a simple file, so copy it self.copy_file(f, self.install_dir) else: # its a tuple with path to install to and a list of files dir = f[0] if not os.path.isabs(dir): dir = os.path.join(self.install_dir, dir) elif self.root: dir = os.path.join(self.root, dir[1:]) self.mkpath(dir) for data in f[1]: self.copy_file(data, dir) | f93105ab00774c131cbc05ed9bcc8ff1c97537e7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f93105ab00774c131cbc05ed9bcc8ff1c97537e7/install_data.py |
print "install_lib: compile=%s, optimize=%s" % \ (`self.compile`, `self.optimize`) | def finalize_options (self): | ac6628ed538f28c8aa05350697c5cbbca3e9a3b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ac6628ed538f28c8aa05350697c5cbbca3e9a3b9/install_lib.py |
|
linelen = 0 | def write(s, output=output, lineEnd='\n'): # RFC 1521 requires that the line ending in a space or tab must have # that trailing character encoded. if s and s[-1:] in ' \t': output.write(s[:-1] + quote(s[-1]) + lineEnd) else: output.write(s + lineEnd) | 50503384fc9729b28fea0707f75fdc1b0a4c4ee6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/50503384fc9729b28fea0707f75fdc1b0a4c4ee6/quopri.py |
|
if linelen + len(c) >= MAXLINESIZE: if prevline is not None: write(prevline) prevline = EMPTYSTRING.join(outline) linelen = 0 outline = [] | def write(s, output=output, lineEnd='\n'): # RFC 1521 requires that the line ending in a space or tab must have # that trailing character encoded. if s and s[-1:] in ' \t': output.write(s[:-1] + quote(s[-1]) + lineEnd) else: output.write(s + lineEnd) | 50503384fc9729b28fea0707f75fdc1b0a4c4ee6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/50503384fc9729b28fea0707f75fdc1b0a4c4ee6/quopri.py |
|
linelen += len(c) | def write(s, output=output, lineEnd='\n'): # RFC 1521 requires that the line ending in a space or tab must have # that trailing character encoded. if s and s[-1:] in ' \t': output.write(s[:-1] + quote(s[-1]) + lineEnd) else: output.write(s + lineEnd) | 50503384fc9729b28fea0707f75fdc1b0a4c4ee6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/50503384fc9729b28fea0707f75fdc1b0a4c4ee6/quopri.py |
|
prevline = EMPTYSTRING.join(outline) linelen = 0 outline = [] | thisline = EMPTYSTRING.join(outline) while len(thisline) > MAXLINESIZE: write(thisline[:MAXLINESIZE-1], lineEnd='=\n') thisline = thisline[MAXLINESIZE-1:] prevline = thisline | def write(s, output=output, lineEnd='\n'): # RFC 1521 requires that the line ending in a space or tab must have # that trailing character encoded. if s and s[-1:] in ' \t': output.write(s[:-1] + quote(s[-1]) + lineEnd) else: output.write(s + lineEnd) | 50503384fc9729b28fea0707f75fdc1b0a4c4ee6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/50503384fc9729b28fea0707f75fdc1b0a4c4ee6/quopri.py |
header.append(mapping[2*i]+256*mapping[2*i+1]) | if sys.byteorder == 'big': header.append(256*mapping[2*i]+mapping[2*i+1]) else: header.append(mapping[2*i]+256*mapping[2*i+1]) | def _optimize_unicode(charset, fixup): charmap = [0]*65536 negate = 0 for op, av in charset: if op is NEGATE: negate = 1 elif op is LITERAL: charmap[fixup(av)] = 1 elif op is RANGE: for i in range(fixup(av[0]), fixup(av[1])+1): charmap[i] = 1 elif op is CATEGORY: # XXX: could expand category return charset # cannot compress if negate: for i in range(65536): charmap[i] = not charmap[i] comps = {} mapping = [0]*256 block = 0 data = [] for i in range(256): chunk = tuple(charmap[i*256:(i+1)*256]) new = comps.setdefault(chunk, block) mapping[i] = new if new == block: block += 1 data += _mk_bitmap(chunk) header = [block] assert MAXCODE == 65535 for i in range(128): header.append(mapping[2*i]+256*mapping[2*i+1]) data[0:0] = header return [(BIGCHARSET, data)] | 1a90052b5bb783167448ffac8179f5c2af18ea7f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1a90052b5bb783167448ffac8179f5c2af18ea7f/sre_compile.py |
def create_inifile (self): | def get_inidata (self): lines = [] | def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst. | 46fa11a9005ba8edc8d0089bc63675ba568773ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/46fa11a9005ba8edc8d0089bc63675ba568773ee/bdist_wininst.py |
ini_name = "%s.ini" % metadata.get_fullname() self.announce ("creating %s" % ini_name) inifile = open (ini_name, "w") | def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst. | 46fa11a9005ba8edc8d0089bc63675ba568773ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/46fa11a9005ba8edc8d0089bc63675ba568773ee/bdist_wininst.py |
|
inifile.write ("[metadata]\n") | lines.append ("[metadata]") | def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst. | 46fa11a9005ba8edc8d0089bc63675ba568773ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/46fa11a9005ba8edc8d0089bc63675ba568773ee/bdist_wininst.py |
inifile.write ("%s=%s\n" % (name, repr (data)[1:-1])) | lines.append ("%s=%s" % (name, repr (data)[1:-1])) | def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst. | 46fa11a9005ba8edc8d0089bc63675ba568773ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/46fa11a9005ba8edc8d0089bc63675ba568773ee/bdist_wininst.py |
inifile.write ("\n[Setup]\n") inifile.write ("info=%s\n" % repr (info)[1:-1]) inifile.write ("pthname=%s.%s\n" % (metadata.name, metadata.version)) | lines.append ("\n[Setup]") lines.append ("info=%s" % repr (info)[1:-1]) lines.append ("pthname=%s.%s" % (metadata.name, metadata.version)) | def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst. | 46fa11a9005ba8edc8d0089bc63675ba568773ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/46fa11a9005ba8edc8d0089bc63675ba568773ee/bdist_wininst.py |
inifile.write ("target_version=%s\n" % self.target_version) | lines.append ("target_version=%s" % self.target_version) | def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst. | 46fa11a9005ba8edc8d0089bc63675ba568773ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/46fa11a9005ba8edc8d0089bc63675ba568773ee/bdist_wininst.py |
inifile.write ("title=%s\n" % repr (title)[1:-1]) inifile.close() return ini_name | lines.append ("title=%s" % repr (title)[1:-1]) return string.join (lines, "\n") | def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst. | 46fa11a9005ba8edc8d0089bc63675ba568773ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/46fa11a9005ba8edc8d0089bc63675ba568773ee/bdist_wininst.py |
import struct cfgdata = open (self.create_inifile()).read() | import struct self.mkpath(self.dist_dir) cfgdata = self.get_inidata() | def create_exe (self, arcname, fullname): import struct#, zlib | 46fa11a9005ba8edc8d0089bc63675ba568773ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/46fa11a9005ba8edc8d0089bc63675ba568773ee/bdist_wininst.py |
self._err_handler = handler.ErrorHandler() | self._err_handler = handler.ErrorHandler() | def __init__(self): self._cont_handler = handler.ContentHandler() #self._dtd_handler = handler.DTDHandler() #self._ent_handler = handler.EntityResolver() self._err_handler = handler.ErrorHandler() | 2d5c793d9ed451a19712d06fbd40696db101927d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d5c793d9ed451a19712d06fbd40696db101927d/xmlreader.py |
def __init__(self, bufsize=2**16 ): self._bufsize=bufsize XMLReader.__init__( self ) def parse(self, source): self.prepareParser(source) inf=open( source ) buffer = inf.read(self._bufsize) | def __init__(self, bufsize=2**16): self._bufsize = bufsize XMLReader.__init__(self) def _parseOpenFile(self, source): buffer = source.read(self._bufsize) | def __init__(self, bufsize=2**16 ): self._bufsize=bufsize XMLReader.__init__( self ) | 2d5c793d9ed451a19712d06fbd40696db101927d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d5c793d9ed451a19712d06fbd40696db101927d/xmlreader.py |
buffer = inf.read(self._bufsize) | buffer = source.read(self._bufsize) | def parse(self, source): self.prepareParser(source) #FIXME: do some type checking: could be already stream, URL or # filename inf=open( source ) buffer = inf.read(self._bufsize) while buffer != "": self.feed(buffer) buffer = inf.read(self._bufsize) self.close() self.reset() | 2d5c793d9ed451a19712d06fbd40696db101927d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d5c793d9ed451a19712d06fbd40696db101927d/xmlreader.py |
if __name__=="__main__": | if __name__ == "__main__": | def _test(): XMLReader() IncrementalParser() Locator() AttributesImpl() | 2d5c793d9ed451a19712d06fbd40696db101927d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d5c793d9ed451a19712d06fbd40696db101927d/xmlreader.py |
host = urlparse.urlparse(req.get_full_url())[1] | host = req.get_host() | def do_open(self, http_class, req): host = urlparse.urlparse(req.get_full_url())[1] if not host: raise URLError('no host given') | 588e408ceb85623e23f58811e069fa2f33012911 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/588e408ceb85623e23f58811e069fa2f33012911/urllib2.py |
if not __debug__: expected = [ev for ev in expected if ev[0] != LINE] | def check_events(self, expected): events = self.get_events_wotime() if not __debug__: # Running under -O, so we don't get LINE events expected = [ev for ev in expected if ev[0] != LINE] if events != expected: self.fail( "events did not match expectation; got:\n%s\nexpected:\n%s" % (pprint.pformat(events), pprint.pformat(expected))) | a1f54b510eacddb9287a2f695dc575acd1977526 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a1f54b510eacddb9287a2f695dc575acd1977526/test_hotshot.py |
|
def start_doctype_decl(self, name, pubid, sysid, has_internal_subset): | def start_doctype_decl(self, name, sysid, pubid, has_internal_subset): | def start_doctype_decl(self, name, pubid, sysid, has_internal_subset): self._lex_handler_prop.startDTD(name, pubid, sysid) | 2186937a8b195f430f6068c37707003b2c901bd5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2186937a8b195f430f6068c37707003b2c901bd5/expatreader.py |
writer.write("\n PUBLIC '%s'\n '%s'" % (self.publicId, self.systemId)) | writer.write("%s PUBLIC '%s'%s '%s'" % (newl, self.publicId, newl, self.systemId)) | def writexml(self, writer, indent="", addindent="", newl=""): writer.write("<!DOCTYPE ") writer.write(self.name) if self.publicId: writer.write("\n PUBLIC '%s'\n '%s'" % (self.publicId, self.systemId)) elif self.systemId: writer.write("\n SYSTEM '%s'" % self.systemId) if self.internalSubset is not None: writer.write(" [") writer.write(self.internalSubset) writer.write("]") writer.write(">\n") | a91c082e5ac1afbf694b067f6d0d9f2c1a744ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a91c082e5ac1afbf694b067f6d0d9f2c1a744ed4/minidom.py |
writer.write("\n SYSTEM '%s'" % self.systemId) | writer.write("%s SYSTEM '%s'" % (newl, self.systemId)) | def writexml(self, writer, indent="", addindent="", newl=""): writer.write("<!DOCTYPE ") writer.write(self.name) if self.publicId: writer.write("\n PUBLIC '%s'\n '%s'" % (self.publicId, self.systemId)) elif self.systemId: writer.write("\n SYSTEM '%s'" % self.systemId) if self.internalSubset is not None: writer.write(" [") writer.write(self.internalSubset) writer.write("]") writer.write(">\n") | a91c082e5ac1afbf694b067f6d0d9f2c1a744ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a91c082e5ac1afbf694b067f6d0d9f2c1a744ed4/minidom.py |
writer.write(">\n") | writer.write(">"+newl) | def writexml(self, writer, indent="", addindent="", newl=""): writer.write("<!DOCTYPE ") writer.write(self.name) if self.publicId: writer.write("\n PUBLIC '%s'\n '%s'" % (self.publicId, self.systemId)) elif self.systemId: writer.write("\n SYSTEM '%s'" % self.systemId) if self.internalSubset is not None: writer.write(" [") writer.write(self.internalSubset) writer.write("]") writer.write(">\n") | a91c082e5ac1afbf694b067f6d0d9f2c1a744ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a91c082e5ac1afbf694b067f6d0d9f2c1a744ed4/minidom.py |
writer.write('<?xml version="1.0" ?>\n') else: writer.write('<?xml version="1.0" encoding="%s"?>\n' % encoding) | writer.write('<?xml version="1.0" ?>'+newl) else: writer.write('<?xml version="1.0" encoding="%s"?>%s' % (encoding, newl)) | def writexml(self, writer, indent="", addindent="", newl="", encoding = None): if encoding is None: writer.write('<?xml version="1.0" ?>\n') else: writer.write('<?xml version="1.0" encoding="%s"?>\n' % encoding) for node in self.childNodes: node.writexml(writer, indent, addindent, newl) | a91c082e5ac1afbf694b067f6d0d9f2c1a744ed4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a91c082e5ac1afbf694b067f6d0d9f2c1a744ed4/minidom.py |
print 'shlex: reading from %s, line %d' % (self.instream,self.lineno) | print 'shlex: reading from %s, line %d' \ % (self.instream, self.lineno) | def __init__(self, instream=None, infile=None): if instream: self.instream = instream self.infile = infile else: self.instream = sys.stdin self.infile = None self.commenters = '#' self.wordchars = 'abcdfeghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' self.whitespace = ' \t\r\n' self.quotes = '\'"' self.state = ' ' self.pushback = []; self.lineno = 1 self.debug = 0 self.token = '' | 12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538/shlex.py |
self.filestack = [(self.infile,self.instream,self.lineno)] + self.filestack | self.filestack.insert(0, (self.infile, self.instream, self.lineno)) | def get_token(self): "Get a token from the input stream (or from stack if it's nonempty)" if self.pushback: tok = self.pushback[0] self.pushback = self.pushback[1:] if self.debug >= 1: print "shlex: popping token " + `tok` return tok | 12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538/shlex.py |
print 'shlex: popping to %s, line %d' % (self.instream, self.lineno) | print 'shlex: popping to %s, line %d' \ % (self.instream, self.lineno) | def get_token(self): "Get a token from the input stream (or from stack if it's nonempty)" if self.pushback: tok = self.pushback[0] self.pushback = self.pushback[1:] if self.debug >= 1: print "shlex: popping token " + `tok` return tok | 12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538/shlex.py |
print "shlex: in state " + repr(self.state) + " I see character: " + repr(nextchar) | print "shlex: in state", repr(self.state), \ "I see character:", repr(nextchar) | def read_token(self): "Read a token from the input stream (no pushback or inclusions)" tok = '' while 1: nextchar = self.instream.read(1); if nextchar == '\n': self.lineno = self.lineno + 1 if self.debug >= 3: print "shlex: in state " + repr(self.state) + " I see character: " + repr(nextchar) if self.state == None: self.token = ''; # past end of file break elif self.state == ' ': if not nextchar: self.state = None; # end of file break elif nextchar in self.whitespace: if self.debug >= 2: print "shlex: I see whitespace in whitespace state" if self.token: break # emit current token else: continue elif nextchar in self.commenters: self.instream.readline() self.lineno = self.lineno + 1 elif nextchar in self.wordchars: self.token = nextchar self.state = 'a' elif nextchar in self.quotes: self.token = nextchar self.state = nextchar else: self.token = nextchar if self.token: break # emit current token else: continue elif self.state in self.quotes: self.token = self.token + nextchar if nextchar == self.state: self.state = ' ' break elif self.state == 'a': if not nextchar: self.state = None; # end of file break elif nextchar in self.whitespace: if self.debug >= 2: print "shlex: I see whitespace in word state" self.state = ' ' if self.token: break # emit current token else: continue elif nextchar in self.commenters: self.instream.readline() self.lineno = self.lineno + 1 elif nextchar in self.wordchars or nextchar in self.quotes: self.token = self.token + nextchar else: self.pushback = [nextchar] + self.pushback if self.debug >= 2: print "shlex: I see punctuation in word state" self.state = ' ' if self.token: break # emit current token else: continue result = self.token self.token = '' if self.debug > 1: if result: print "shlex: raw token=" + `result` else: print "shlex: raw token=EOF" return result | 12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538/shlex.py |
lexer = shlex() | if len(sys.argv) == 1: lexer = shlex() else: file = sys.argv[1] lexer = shlex(open(file), file) | def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." if not infile: infile = self.infile if not lineno: lineno = self.lineno return "\"%s\", line %d: " % (infile, lineno) | 12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538/shlex.py |
print "Token: " + repr(tt) if not tt: | if tt: print "Token: " + repr(tt) else: | def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." if not infile: infile = self.infile if not lineno: lineno = self.lineno return "\"%s\", line %d: " % (infile, lineno) | 12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538/shlex.py |
def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." if not infile: infile = self.infile if not lineno: lineno = self.lineno return "\"%s\", line %d: " % (infile, lineno) | 12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/12ff9e258c4cbae402cb9ff8dd5bb4aa2eb3b538/shlex.py |
||
def __init__(self, filename=None, mode=None, | f1409e06ab5e40cc3e2a8762690b55a092008400 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f1409e06ab5e40cc3e2a8762690b55a092008400/gzip.py |
||
if not size: | readsize = 1024 if not size: | def read(self,size=None): | f1409e06ab5e40cc3e2a8762690b55a092008400 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f1409e06ab5e40cc3e2a8762690b55a092008400/gzip.py |
self._read() | self._read(readsize) readsize = readsize * 2 | def read(self,size=None): | f1409e06ab5e40cc3e2a8762690b55a092008400 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f1409e06ab5e40cc3e2a8762690b55a092008400/gzip.py |
else: | else: | def read(self,size=None): | f1409e06ab5e40cc3e2a8762690b55a092008400 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f1409e06ab5e40cc3e2a8762690b55a092008400/gzip.py |
self._read() | self._read(readsize) readsize = readsize * 2 | def read(self,size=None): | f1409e06ab5e40cc3e2a8762690b55a092008400 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f1409e06ab5e40cc3e2a8762690b55a092008400/gzip.py |
def _read(self): buf = self.fileobj.read(1024) | def _unread(self, buf): self.extrabuf = buf + self.extrabuf self.extrasize = len(buf) + self.extrasize def _read(self, size=1024): try: buf = self.fileobj.read(size) except AttributeError: raise EOFError, "Reached EOF" | def _read(self): | f1409e06ab5e40cc3e2a8762690b55a092008400 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f1409e06ab5e40cc3e2a8762690b55a092008400/gzip.py |
line="" | bufs = [] readsize = 100 | def readline(self): | f1409e06ab5e40cc3e2a8762690b55a092008400 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f1409e06ab5e40cc3e2a8762690b55a092008400/gzip.py |
c = self.read(1) line = line + c if c=='\n' or c=="": break return line | c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2 | def readline(self): | f1409e06ab5e40cc3e2a8762690b55a092008400 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f1409e06ab5e40cc3e2a8762690b55a092008400/gzip.py |
L=[] line = self.readline() while line!="": L.append(line) line = self.readline() return L | buf = self.read() return string.split(buf, '\n') | def readlines(self): | f1409e06ab5e40cc3e2a8762690b55a092008400 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f1409e06ab5e40cc3e2a8762690b55a092008400/gzip.py |
if islink(component): resolved = os.readlink(component) (dir, file) = split(component) resolved = normpath(join(dir, resolved)) newpath = join(*([resolved] + bits[i:])) return realpath(newpath) | if islink(component): resolved = _resolve_link(component) if resolved is None: return join(*([component] + bits[i:])) else: newpath = join(*([resolved] + bits[i:])) return realpath(newpath) | def realpath(filename): """Return the canonical path of the specified filename, eliminating any | 5e2231323420938944994cc25e60d37fe3a34de5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5e2231323420938944994cc25e60d37fe3a34de5/posixpath.py |
os.mkdir(dst) | os.makedirs(dst) copystat(src, dst) | def copytree(src, dst, symlinks=False): """Recursively copy a directory tree using copy2(). The destination directory must not already exist. If exception(s) occur, an Error is raised with a list of reasons. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. XXX Consider this example code rather than the ultimate tool. """ names = os.listdir(src) os.mkdir(dst) errors = [] for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) try: if symlinks and os.path.islink(srcname): linkto = os.readlink(srcname) os.symlink(linkto, dstname) elif os.path.isdir(srcname): copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) # XXX What about devices, sockets etc.? except (IOError, os.error), why: errors.append((srcname, dstname, why)) if errors: raise Error, errors | 48f3ea9a2c4d1cbade55a9ebfa99ff213338f948 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/48f3ea9a2c4d1cbade55a9ebfa99ff213338f948/shutil.py |
dupDB.associate(secDB, lambda a, b: a+b) | def f(a,b): return a+b dupDB.associate(secDB, f) | def test00_associateDBError(self): if verbose: print '\n', '-=' * 30 print "Running %s.test00_associateDBError..." % \ self.__class__.__name__ | 4d44dec36295fb3edf7e6b9cf199afb5f1139ee2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4d44dec36295fb3edf7e6b9cf199afb5f1139ee2/test_associate.py |
self.primary.open(self.filename, "primary", self.dbtype, | if db.version() >= (4, 1): self.primary.open(self.filename, "primary", self.dbtype, | def createDB(self, txn=None): | 4d44dec36295fb3edf7e6b9cf199afb5f1139ee2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4d44dec36295fb3edf7e6b9cf199afb5f1139ee2/test_associate.py |
self.getDB().associate(self.secDB, self.getGenre, txn=txn) | if db.version() >= (4,1): self.getDB().associate(self.secDB, self.getGenre, txn=txn) else: self.getDB().associate(self.secDB, self.getGenre) | def test13_associate_in_transaction(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__ | 4d44dec36295fb3edf7e6b9cf199afb5f1139ee2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4d44dec36295fb3edf7e6b9cf199afb5f1139ee2/test_associate.py |
suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase)) | if db.version() >= (4, 1): suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase)) | def test_suite(): suite = unittest.TestSuite() if db.version() >= (3, 3, 11): suite.addTest(unittest.makeSuite(AssociateErrorTestCase)) suite.addTest(unittest.makeSuite(AssociateHashTestCase)) suite.addTest(unittest.makeSuite(AssociateBTreeTestCase)) suite.addTest(unittest.makeSuite(AssociateRecnoTestCase)) suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase)) suite.addTest(unittest.makeSuite(ShelveAssociateHashTestCase)) suite.addTest(unittest.makeSuite(ShelveAssociateBTreeTestCase)) suite.addTest(unittest.makeSuite(ShelveAssociateRecnoTestCase)) if have_threads: suite.addTest(unittest.makeSuite(ThreadedAssociateHashTestCase)) suite.addTest(unittest.makeSuite(ThreadedAssociateBTreeTestCase)) suite.addTest(unittest.makeSuite(ThreadedAssociateRecnoTestCase)) return suite | 4d44dec36295fb3edf7e6b9cf199afb5f1139ee2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4d44dec36295fb3edf7e6b9cf199afb5f1139ee2/test_associate.py |
self.copy_file(name, outfile, preserve_mode = 0) | self.copy_file(os.path.join(package_dir, name), outfile, preserve_mode = 0) | def run(self): # Copies all .py files, then also copies the txt and gif files build_py.run(self) assert self.packages == [idlelib] for name in txt_files: outfile = self.get_plain_outfile(self.build_lib, [idlelib], name) dir = os.path.dirname(outfile) self.mkpath(dir) self.copy_file(name, outfile, preserve_mode = 0) for name in Icons: outfile = self.get_plain_outfile(self.build_lib, [idlelib,"Icons"], name) dir = os.path.dirname(outfile) self.mkpath(dir) self.copy_file(os.path.join("Icons",name), outfile, preserve_mode = 0) | a3c4ce3d80ef72974f6f47d101fc7671bea4c55b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a3c4ce3d80ef72974f6f47d101fc7671bea4c55b/setup.py |
icons = [os.path.join("Icons",name) for name in Icons] | icons = [os.path.join(package_dir, "Icons",name) for name in Icons] txts = [os.path.join(package_dir, name) for name in txt_files] | def get_source_files(self): # returns the .py files, the .txt files, and the icons icons = [os.path.join("Icons",name) for name in Icons] return build_py.get_source_files(self)+txt_files+icons | a3c4ce3d80ef72974f6f47d101fc7671bea4c55b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a3c4ce3d80ef72974f6f47d101fc7671bea4c55b/setup.py |
package_dir = {idlelib:'.'}, | package_dir = {idlelib: package_dir}, | def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files) | a3c4ce3d80ef72974f6f47d101fc7671bea4c55b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a3c4ce3d80ef72974f6f47d101fc7671bea4c55b/setup.py |
scripts = ['idle'] | scripts = [os.path.join(package_dir, 'idle')] | def _bytecode_filenames(self, files): files = [n for n in files if n.endswith('.py')] return install_lib._bytecode_filenames(self,files) | a3c4ce3d80ef72974f6f47d101fc7671bea4c55b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a3c4ce3d80ef72974f6f47d101fc7671bea4c55b/setup.py |
def err(args): | def err(*args): | def err(args): savestdout = sys.stdout try: sys.stdout = sys.stderr for i in args: print i, print finally: sys.stdout = savestdout | 6f0fa184056f6f90de6fc2c0546e39bcffc996e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6f0fa184056f6f90de6fc2c0546e39bcffc996e6/cgen.py |
e = 'Function', func, 'too complicated:' err(e + (a_type, a_mode, a_factor, a_sub)) | err('Function', func, 'too complicated:', a_type, a_mode, a_factor, a_sub) | def generate(type, func, database): # # Check that we can handle this case: # no variable size reply arrays yet # n_in_args = 0 n_out_args = 0 # for a_type, a_mode, a_factor, a_sub in database: if a_mode == 's': n_in_args = n_in_args + 1 elif a_mode == 'r': n_out_args = n_out_args + 1 else: # Can't happen raise arg_error, ('bad a_mode', a_mode) if (a_mode == 'r' and a_sub) or a_sub == 'retval': e = 'Function', func, 'too complicated:' err(e + (a_type, a_mode, a_factor, a_sub)) print '/* XXX Too complicated to generate code for */' return # functions.append(func) # # Stub header # print print 'static object *' print 'gl_' + func + '(self, args)' print '\tobject *self;' print '\tobject *args;' print '{' # # Declare return value if any # if type <> 'void': print '\t' + type, 'retval;' # # Declare arguments # for i in range(len(database)): a_type, a_mode, a_factor, a_sub = database[i] print '\t' + a_type, brac = ket = '' if a_sub and not isnum(a_sub): if a_factor: brac = '(' ket = ')' print brac + '*', print 'arg' + `i+1` + ket, if a_sub and isnum(a_sub): print '[', a_sub, ']', if a_factor: print '[', a_factor, ']', print ';' # # Find input arguments derived from array sizes # for i in range(len(database)): a_type, a_mode, a_factor, a_sub = database[i] if a_mode == 's' and a_sub[:3] == 'arg' and isnum(a_sub[3:]): # Sending a variable-length array n = eval(a_sub[3:]) if 1 <= n <= len(database): b_type, b_mode, b_factor, b_sub = database[n-1] if b_mode == 's': database[n-1] = b_type, 'i', a_factor, `i` n_in_args = n_in_args - 1 # # Assign argument positions in the Python argument list # in_pos = [] i_in = 0 for i in range(len(database)): a_type, a_mode, a_factor, a_sub = database[i] if a_mode == 's': in_pos.append(i_in) i_in = i_in + 1 else: in_pos.append(-1) # # Get input arguments # for i in range(len(database)): a_type, a_mode, a_factor, a_sub = database[i] if a_type[:9] == 'unsigned ': xtype = a_type[9:] else: xtype = a_type if a_mode == 'i': # # Implicit argument; # a_factor is divisor if present, # a_sub indicates which arg (`database index`) # j = eval(a_sub) print '\tif', print '(!geti' + xtype + 'arraysize(args,', print `n_in_args` + ',', print `in_pos[j]` + ',', if xtype <> a_type: print '('+xtype+' *)', print '&arg' + `i+1` + '))' print '\t\treturn NULL;' if a_factor: print '\targ' + `i+1`, print '= arg' + `i+1`, print '/', a_factor + ';' elif a_mode == 's': if a_sub and not isnum(a_sub): # Allocate memory for varsize array print '\tif ((arg' + `i+1`, '=', if a_factor: print '('+a_type+'(*)['+a_factor+'])', print 'NEW(' + a_type, ',', if a_factor: print a_factor, '*', print a_sub, ')) == NULL)' print '\t\treturn err_nomem();' print '\tif', if a_factor or a_sub: # Get a fixed-size array array print '(!geti' + xtype + 'array(args,', print `n_in_args` + ',', print `in_pos[i]` + ',', if a_factor: print a_factor, if a_factor and a_sub: print '*', if a_sub: print a_sub, print ',', if (a_sub and a_factor) or xtype <> a_type: print '('+xtype+' *)', print 'arg' + `i+1` + '))' else: # Get a simple variable print '(!geti' + xtype + 'arg(args,', print `n_in_args` + ',', print `in_pos[i]` + ',', if xtype <> a_type: print '('+xtype+' *)', print '&arg' + `i+1` + '))' print '\t\treturn NULL;' # # Begin of function call # if type <> 'void': print '\tretval =', func + '(', else: print '\t' + func + '(', # # Argument list # for i in range(len(database)): if i > 0: print ',', a_type, a_mode, a_factor, a_sub = database[i] if a_mode == 'r' and not a_factor: print '&', print 'arg' + `i+1`, # # End of function call # print ');' # # Free varsize arrays # for i in range(len(database)): a_type, a_mode, a_factor, a_sub = database[i] if a_mode == 's' and a_sub and not isnum(a_sub): print '\tDEL(arg' + `i+1` + ');' # # Return # if n_out_args: # # Multiple return values -- construct a tuple # if type <> 'void': n_out_args = n_out_args + 1 if n_out_args == 1: for i in range(len(database)): a_type, a_mode, a_factor, a_sub = database[i] if a_mode == 'r': break else: raise arg_error, 'expected r arg not found' print '\treturn', print mkobject(a_type, 'arg' + `i+1`) + ';' else: print '\t{ object *v = newtupleobject(', print n_out_args, ');' print '\t if (v == NULL) return NULL;' i_out = 0 if type <> 'void': print '\t settupleitem(v,', print `i_out` + ',', print mkobject(type, 'retval') + ');' i_out = i_out + 1 for i in range(len(database)): a_type, a_mode, a_factor, a_sub = database[i] if a_mode == 'r': print '\t settupleitem(v,', print `i_out` + ',', s = mkobject(a_type, 'arg' + `i+1`) print s + ');' i_out = i_out + 1 print '\t return v;' print '\t}' else: # # Simple function return # Return None or return value # if type == 'void': print '\tINCREF(None);' print '\treturn None;' else: print '\treturn', mkobject(type, 'retval') + ';' # # Stub body closing brace # print '}' | 6f0fa184056f6f90de6fc2c0546e39bcffc996e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6f0fa184056f6f90de6fc2c0546e39bcffc996e6/cgen.py |
sys.path.append('/ufs/guido/src/video') | sys.path.append('/ufs/jack/src/av/video') | def help(): print 'Usage: video2rgb [options] [file] ...' print print 'Options:' print '-q : quiet, no informative messages' print '-m : create monochrome (greyscale) image files' print '-f prefix : create image files with names "prefix0000.rgb"' print 'file ... : file(s) to convert; default film.video' | b500ee81297d7ad5c24061bc3c09bc097d1204b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b500ee81297d7ad5c24061bc3c09bc097d1204b5/video2rgb.py |
m=None | m = (None, None) | def quoteaddr(addr): """Quote a subset of the email addresses defined by RFC 821. Should be able to handle anything rfc822.parseaddr can handle. """ m=None try: m=rfc822.parseaddr(addr)[1] except AttributeError: pass if not m: #something weird here.. punt -ddm return addr else: return "<%s>" % m | 04a33f8d98c7335f2e18350cb748c62d89a9baeb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/04a33f8d98c7335f2e18350cb748c62d89a9baeb/smtplib.py |
if not m: | if m == (None, None): | def quoteaddr(addr): """Quote a subset of the email addresses defined by RFC 821. Should be able to handle anything rfc822.parseaddr can handle. """ m=None try: m=rfc822.parseaddr(addr)[1] except AttributeError: pass if not m: #something weird here.. punt -ddm return addr else: return "<%s>" % m | 04a33f8d98c7335f2e18350cb748c62d89a9baeb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/04a33f8d98c7335f2e18350cb748c62d89a9baeb/smtplib.py |
return addr | return "<%s>" % addr | def quoteaddr(addr): """Quote a subset of the email addresses defined by RFC 821. Should be able to handle anything rfc822.parseaddr can handle. """ m=None try: m=rfc822.parseaddr(addr)[1] except AttributeError: pass if not m: #something weird here.. punt -ddm return addr else: return "<%s>" % m | 04a33f8d98c7335f2e18350cb748c62d89a9baeb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/04a33f8d98c7335f2e18350cb748c62d89a9baeb/smtplib.py |
if kwargs.has_key('command') | if kwargs.has_key('command'): | def __init__(self, master, variable, value, *values, **kwargs): kw = {"borderwidth": 2, "textvariable": variable, "indicatoron": 1, "relief": RAISED, "anchor": "c", "highlightthickness": 2} Widget.__init__(self, master, "menubutton", kw) self.widgetName = 'tk_optionMenu' menu = self.__menu = Menu(self, name="menu", tearoff=0) self.menuname = menu._w # 'command' is the only supported keyword callback = kwargs.get('command') if kwargs.has_key('command') del kwargs['command'] if kwargs: raise TclError, 'unknown option -'+kwargs.keys()[0] menu.add_command(label=value, command=_setit(variable, value, callback)) for v in values: menu.add_command(label=v, command=_setit(variable, v, callback)) self["menu"] = menu | 91b1425797226e5b2cbacf628ecca3a41195b356 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/91b1425797226e5b2cbacf628ecca3a41195b356/Tkinter.py |
s = marshal.dumps(f) | s = marshal.dumps(f, 2) | def test_floats(self): # Test a few floats small = 1e-25 n = sys.maxint * 3.7e250 while n > small: for expected in (-n, n): f = float(expected) s = marshal.dumps(f) got = marshal.loads(s) self.assertEqual(f, got) marshal.dump(f, file(test_support.TESTFN, "wb")) got = marshal.load(file(test_support.TESTFN, "rb")) self.assertEqual(f, got) n /= 123.4567 | 72aad72c74b370781a69de719c4029b7b10bed29 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/72aad72c74b370781a69de719c4029b7b10bed29/test_marshal.py |
fp = open(MOFILE, 'w') | fp = open(MOFILE, 'wb') | def setup(): os.makedirs(LOCALEDIR) fp = open(MOFILE, 'w') fp.write(base64.decodestring(GNU_MO_DATA)) fp.close() | e31a7e6cf0b073bf6e7b29556ba805e09197a12c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e31a7e6cf0b073bf6e7b29556ba805e09197a12c/test_gettext.py |
packkey(ae, key, value) | ae.AEPutAttributeDesc(key, pack(value)) | def packevent(ae, parameters = {}, attributes = {}): for key, value in parameters.items(): packkey(ae, key, value) for key, value in attributes.items(): packkey(ae, key, value) | 1634e38e363cf31965bdc24f5b1fcf1a5b0c0bb9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1634e38e363cf31965bdc24f5b1fcf1a5b0c0bb9/aetools.py |
arguments[key] = edict[v] | arguments[key] = Enum(edict[v]) | def enumsubst(arguments, key, edict): """Substitute a single enum keyword argument, if it occurs""" if not arguments.has_key(key) or edict is None: return v = arguments[key] ok = edict.values() if edict.has_key(v): arguments[key] = edict[v] elif not v in ok: raise TypeError, 'Unknown enumerator: %s'%v | 1634e38e363cf31965bdc24f5b1fcf1a5b0c0bb9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1634e38e363cf31965bdc24f5b1fcf1a5b0c0bb9/aetools.py |
opt_dict[opt] = (filename, parser.get(section,opt)) | val = parser.get(section,opt) opt = string.replace(opt, '-', '_') opt_dict[opt] = (filename, val) | def parse_config_files (self, filenames=None): | 8919bf51cbe9834ffb64922ee69a61816bf2fab0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8919bf51cbe9834ffb64922ee69a61816bf2fab0/dist.py |
true if command-line were successfully parsed and we should carry | true if command-line was successfully parsed and we should carry | def parse_command_line (self): """Parse the setup script's command line, taken from the 'script_args' instance attribute (which defaults to 'sys.argv[1:]' -- see 'setup()' in core.py). This list is first processed for "global options" -- options that set attributes of the Distribution instance. Then, it is alternately scanned for Distutils commands and options for that command. Each new command terminates the options for the previous command. The allowed options for a command are determined by the 'user_options' attribute of the command class -- thus, we have to be able to load command classes in order to parse the command line. Any error in that 'options' attribute raises DistutilsGetoptError; any error on the command-line raises DistutilsArgError. If no Distutils commands were found on the command line, raises DistutilsArgError. Return true if command-line were successfully parsed and we should carry on with executing commands; false if no errors but we shouldn't execute commands (currently, this only happens if user asks for help). """ # We have to parse the command line a bit at a time -- global # options, then the first command, then its options, and so on -- # because each command will be handled by a different class, and # the options that are valid for a particular class aren't known # until we have loaded the command class, which doesn't happen # until we know what the command is. | 8919bf51cbe9834ffb64922ee69a61816bf2fab0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8919bf51cbe9834ffb64922ee69a61816bf2fab0/dist.py |
'command_obj' must be a Commnd instance. If 'option_dict' is not | 'command_obj' must be a Command instance. If 'option_dict' is not | def _set_command_options (self, command_obj, option_dict=None): """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). | 8919bf51cbe9834ffb64922ee69a61816bf2fab0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8919bf51cbe9834ffb64922ee69a61816bf2fab0/dist.py |
if not hasattr(command_obj, option): raise DistutilsOptionError, \ ("error in %s: command '%s' has no such option '%s'") % \ (source, command_name, option) setattr(command_obj, option, value) | try: bool_opts = command_obj.boolean_options except AttributeError: bool_opts = [] try: neg_opt = command_obj.negative_opt except AttributeError: neg_opt = {} try: if neg_opt.has_key(option): setattr(command_obj, neg_opt[option], not strtobool(value)) elif option in bool_opts: setattr(command_obj, option, strtobool(value)) elif hasattr(command_obj, option): setattr(command_obj, option, value) else: raise DistutilsOptionError, \ ("error in %s: command '%s' has no such option '%s'" % (source, command_name, option)) except ValueError, msg: raise DistutilsOptionError, msg | def _set_command_options (self, command_obj, option_dict=None): """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). | 8919bf51cbe9834ffb64922ee69a61816bf2fab0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8919bf51cbe9834ffb64922ee69a61816bf2fab0/dist.py |
os.execve(scriptfile, args, env) | os.execve(scriptfile, args, os.environ) | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2 or self.have_popen3): self.send_error(403, "CGI script is not a Python script (%s)" % `scriptname`) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return | 3b884c05567a557bf75367102944903d9657d2c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3b884c05567a557bf75367102944903d9657d2c0/CGIHTTPServer.py |
self.error("expected name token") | self.error("expected name token at %r" % rawdata[declstartpos:declstartpos+20]) | def _scan_name(self, i, declstartpos): rawdata = self.rawdata n = len(rawdata) if i == n: return None, -1 m = _declname_match(rawdata, i) if m: s = m.group() name = s.strip() if (i + len(s)) == n: return None, -1 # end of buffer return name.lower(), m.end() else: self.updatepos(declstartpos, i) self.error("expected name token") | 5495e33481d4c053ea2bc44dcaea1268ee5724ea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5495e33481d4c053ea2bc44dcaea1268ee5724ea/markupbase.py |
st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode) | if hasattr(os, 'chmod'): st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode) | def copymode(src, dst): """Copy mode bits from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode) | 27f410fe7fc3510002f55d8f913a5013585914a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/27f410fe7fc3510002f55d8f913a5013585914a9/shutil.py |
os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) os.chmod(dst, mode) | if hasattr(os, 'utime'): os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) if hasattr(os, 'chmod'): os.chmod(dst, mode) | def copystat(src, dst): """Copy all stat info (mode bits, atime and mtime) from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) os.chmod(dst, mode) | 27f410fe7fc3510002f55d8f913a5013585914a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/27f410fe7fc3510002f55d8f913a5013585914a9/shutil.py |
setup(width=_width, height= _height, startx=_startx, starty=_starty) | setup(width=_width, height= _height, startx=_startx, starty=_starty) | def __init__(self): global _root, _canvas if _root is None: _root = Tkinter.Tk() _root.wm_protocol("WM_DELETE_WINDOW", self._destroy) _root.title(_title) | 7b89d601609132aab5db317c8195fa1aa14ac36f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7b89d601609132aab5db317c8195fa1aa14ac36f/turtle.py |
matches = (['class', name], ['class', name + ':']) | pat = re.compile(r'^\s*class\s*' + name + r'\b') | def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" try: file = open(getsourcefile(object)) except (TypeError, IOError): raise IOError, 'could not get source code' lines = file.readlines() file.close() if ismodule(object): return lines, 0 if isclass(object): name = object.__name__ matches = (['class', name], ['class', name + ':']) for i in range(len(lines)): if string.split(lines[i])[:2] in matches: return lines, i else: raise IOError, 'could not find class definition' if ismethod(object): object = object.im_func if isfunction(object): object = object.func_code if istraceback(object): object = object.tb_frame if isframe(object): object = object.f_code if iscode(object): if not hasattr(object, 'co_firstlineno'): raise IOError, 'could not find function definition' lnum = object.co_firstlineno - 1 while lnum > 0: if string.split(lines[lnum])[:1] == ['def']: break lnum = lnum - 1 return lines, lnum | 704c314f4179203a24c494f2a40dd915600f9c28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/704c314f4179203a24c494f2a40dd915600f9c28/inspect.py |
if string.split(lines[i])[:2] in matches: return lines, i | if pat.match(lines[i]): return lines, i | def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" try: file = open(getsourcefile(object)) except (TypeError, IOError): raise IOError, 'could not get source code' lines = file.readlines() file.close() if ismodule(object): return lines, 0 if isclass(object): name = object.__name__ matches = (['class', name], ['class', name + ':']) for i in range(len(lines)): if string.split(lines[i])[:2] in matches: return lines, i else: raise IOError, 'could not find class definition' if ismethod(object): object = object.im_func if isfunction(object): object = object.func_code if istraceback(object): object = object.tb_frame if isframe(object): object = object.f_code if iscode(object): if not hasattr(object, 'co_firstlineno'): raise IOError, 'could not find function definition' lnum = object.co_firstlineno - 1 while lnum > 0: if string.split(lines[lnum])[:1] == ['def']: break lnum = lnum - 1 return lines, lnum | 704c314f4179203a24c494f2a40dd915600f9c28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/704c314f4179203a24c494f2a40dd915600f9c28/inspect.py |
if string.split(lines[lnum])[:1] == ['def']: break | if pat.match(lines[lnum]): break | def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" try: file = open(getsourcefile(object)) except (TypeError, IOError): raise IOError, 'could not get source code' lines = file.readlines() file.close() if ismodule(object): return lines, 0 if isclass(object): name = object.__name__ matches = (['class', name], ['class', name + ':']) for i in range(len(lines)): if string.split(lines[i])[:2] in matches: return lines, i else: raise IOError, 'could not find class definition' if ismethod(object): object = object.im_func if isfunction(object): object = object.func_code if istraceback(object): object = object.tb_frame if isframe(object): object = object.f_code if iscode(object): if not hasattr(object, 'co_firstlineno'): raise IOError, 'could not find function definition' lnum = object.co_firstlineno - 1 while lnum > 0: if string.split(lines[lnum])[:1] == ['def']: break lnum = lnum - 1 return lines, lnum | 704c314f4179203a24c494f2a40dd915600f9c28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/704c314f4179203a24c494f2a40dd915600f9c28/inspect.py |
print 'h=',h | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | 0b424aeee61cf467f726567c4a8deb7458742940 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0b424aeee61cf467f726567c4a8deb7458742940/VCR.py |
|
print 'm=',m | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | 0b424aeee61cf467f726567c4a8deb7458742940 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0b424aeee61cf467f726567c4a8deb7458742940/VCR.py |
|
print 's=',s | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | 0b424aeee61cf467f726567c4a8deb7458742940 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0b424aeee61cf467f726567c4a8deb7458742940/VCR.py |
|
print 'f=',f | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | 0b424aeee61cf467f726567c4a8deb7458742940 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0b424aeee61cf467f726567c4a8deb7458742940/VCR.py |
|
if self.re._num_regs == 1: return () return apply(self.group, tuple(range(1, self.re._num_regs) ) ) | result = [] for g in range(1, self.re._num_regs): if (self.regs[g][0] == -1) or (self.regs[g][1] == -1): result.append(None) else: result.append(self.string[self.regs[g][0]:self.regs[g][1]]) return tuple(result) | def groups(self): | 94bba56373198613662f048b2c37f1963cae2e39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/94bba56373198613662f048b2c37f1963cae2e39/re.py |
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): | def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False): | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. | The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, use_resources, and trace) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', | opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:T', | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
'findleaks', 'use=', 'threshold=']) | 'findleaks', 'use=', 'threshold=', 'trace', ]) | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
quiet = 1; | quiet = True; | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
generate = 1 | generate = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
exclude = 1 | exclude = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
single = 1 | single = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
randomize = 1 | randomize = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
findleaks = 1 | findleaks = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
findleaks = 0 | findleaks = False | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) | if trace: tracer.runctx('runtest(test, generate, verbose, quiet, testdir)', globals=globals(), locals=vars()) | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
skipped.append(test) if ok == -2: resource_denieds.append(test) | ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) sys.exit(len(bad) > 0) | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
def runtest(test, generate, verbose, quiet, testdir = None): | def runtest(test, generate, verbose, quiet, testdir=None): | def runtest(test, generate, verbose, quiet, testdir = None): """Run a single test. test -- the name of the test generate -- if true, generate output, instead of running the test and comparing it to a previously created output file verbose -- if true, print more messages quiet -- if true, don't print 'skipped' messages (probably redundant) testdir -- test directory """ test_support.unload(test) if not testdir: testdir = findtestdir() outputdir = os.path.join(testdir, "output") outputfile = os.path.join(outputdir, test) if verbose: cfp = None else: cfp = cStringIO.StringIO() try: save_stdout = sys.stdout try: if cfp: sys.stdout = cfp print test # Output file starts with test name if test.startswith('test.'): abstest = test else: # Always import it from the test package abstest = 'test.' + test the_package = __import__(abstest, globals(), locals(), []) the_module = getattr(the_package, test) # Most tests run to completion simply as a side-effect of # being imported. For the benefit of tests that can't run # that way (like test_threaded_import), explicitly invoke # their test_main() function (if it exists). indirect_test = getattr(the_module, "test_main", None) if indirect_test is not None: indirect_test() finally: sys.stdout = save_stdout except test_support.ResourceDenied, msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() return -2 except (ImportError, test_support.TestSkipped), msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() return -1 except KeyboardInterrupt: raise except test_support.TestFailed, msg: print "test", test, "failed --", msg sys.stdout.flush() return 0 except: type, value = sys.exc_info()[:2] print "test", test, "crashed --", str(type) + ":", value sys.stdout.flush() if verbose: traceback.print_exc(file=sys.stdout) sys.stdout.flush() return 0 else: if not cfp: return 1 output = cfp.getvalue() if generate: if output == test + "\n": if os.path.exists(outputfile): # Write it since it already exists (and the contents # may have changed), but let the user know it isn't # needed: print "output file", outputfile, \ "is no longer needed; consider removing it" else: # We don't need it, so don't create it. return 1 fp = open(outputfile, "w") fp.write(output) fp.close() return 1 if os.path.exists(outputfile): fp = open(outputfile, "r") expected = fp.read() fp.close() else: expected = test + "\n" if output == expected: return 1 print "test", test, "produced unexpected output:" sys.stdout.flush() reportdiff(expected, output) sys.stdout.flush() return 0 | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
if not testdir: testdir = findtestdir() | if not testdir: testdir = findtestdir() | def runtest(test, generate, verbose, quiet, testdir = None): """Run a single test. test -- the name of the test generate -- if true, generate output, instead of running the test and comparing it to a previously created output file verbose -- if true, print more messages quiet -- if true, don't print 'skipped' messages (probably redundant) testdir -- test directory """ test_support.unload(test) if not testdir: testdir = findtestdir() outputdir = os.path.join(testdir, "output") outputfile = os.path.join(outputdir, test) if verbose: cfp = None else: cfp = cStringIO.StringIO() try: save_stdout = sys.stdout try: if cfp: sys.stdout = cfp print test # Output file starts with test name if test.startswith('test.'): abstest = test else: # Always import it from the test package abstest = 'test.' + test the_package = __import__(abstest, globals(), locals(), []) the_module = getattr(the_package, test) # Most tests run to completion simply as a side-effect of # being imported. For the benefit of tests that can't run # that way (like test_threaded_import), explicitly invoke # their test_main() function (if it exists). indirect_test = getattr(the_module, "test_main", None) if indirect_test is not None: indirect_test() finally: sys.stdout = save_stdout except test_support.ResourceDenied, msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() return -2 except (ImportError, test_support.TestSkipped), msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() return -1 except KeyboardInterrupt: raise except test_support.TestFailed, msg: print "test", test, "failed --", msg sys.stdout.flush() return 0 except: type, value = sys.exc_info()[:2] print "test", test, "crashed --", str(type) + ":", value sys.stdout.flush() if verbose: traceback.print_exc(file=sys.stdout) sys.stdout.flush() return 0 else: if not cfp: return 1 output = cfp.getvalue() if generate: if output == test + "\n": if os.path.exists(outputfile): # Write it since it already exists (and the contents # may have changed), but let the user know it isn't # needed: print "output file", outputfile, \ "is no longer needed; consider removing it" else: # We don't need it, so don't create it. return 1 fp = open(outputfile, "w") fp.write(output) fp.close() return 1 if os.path.exists(outputfile): fp = open(outputfile, "r") expected = fp.read() fp.close() else: expected = test + "\n" if output == expected: return 1 print "test", test, "produced unexpected output:" sys.stdout.flush() reportdiff(expected, output) sys.stdout.flush() return 0 | 3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3feaba6409bd3f4dce920f7a4f22e9e9361f6c5f/regrtest.py |
path = os.path.join(os.path.dirname(test_email.__file__), 'data', filename) | path = os.path.join(os.path.dirname(test_support_file), 'data', filename) | def openfile(filename): path = os.path.join(os.path.dirname(test_email.__file__), 'data', filename) return open(path) | 8df007729a0ab41938bd335c03f6e3934746c2ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8df007729a0ab41938bd335c03f6e3934746c2ff/test_email.py |
if __name__ == '__main__': unittest.main(defaultTest='suite') else: | def test_main(): | def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestMessageAPI)) suite.addTest(unittest.makeSuite(TestEncoders)) suite.addTest(unittest.makeSuite(TestLongHeaders)) suite.addTest(unittest.makeSuite(TestFromMangling)) suite.addTest(unittest.makeSuite(TestMIMEAudio)) suite.addTest(unittest.makeSuite(TestMIMEImage)) suite.addTest(unittest.makeSuite(TestMIMEText)) suite.addTest(unittest.makeSuite(TestMultipartMixed)) suite.addTest(unittest.makeSuite(TestNonConformant)) suite.addTest(unittest.makeSuite(TestRFC2047)) suite.addTest(unittest.makeSuite(TestMIMEMessage)) suite.addTest(unittest.makeSuite(TestIdempotent)) suite.addTest(unittest.makeSuite(TestMiscellaneous)) suite.addTest(unittest.makeSuite(TestIterators)) suite.addTest(unittest.makeSuite(TestParsers)) return suite | 8df007729a0ab41938bd335c03f6e3934746c2ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8df007729a0ab41938bd335c03f6e3934746c2ff/test_email.py |
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', '')) | def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', '')) | 5cf26e5184cafd0f87ad4cafc52ed5b635df0d4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5cf26e5184cafd0f87ad4cafc52ed5b635df0d4a/csv.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.