rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
if not self.py_modules and not self.packages: return if self.py_modules and self.packages: raise DistutilsOptionError, \ "build_py: supplying both 'packages' and 'py_modules' " + \ "options is not allowed"
def run (self):
bb7ab6f2da512ae49ba5305c52bfb2e3d073391c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bb7ab6f2da512ae49ba5305c52bfb2e3d073391c/build_py.py
else:
if self.packages:
def run (self):
bb7ab6f2da512ae49ba5305c52bfb2e3d073391c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bb7ab6f2da512ae49ba5305c52bfb2e3d073391c/build_py.py
modules = self.find_modules() else: modules = []
modules.extend(self.find_modules()) if self.packages:
def find_all_modules (self): """Compute the list of all modules that will be built, whether they are specified one-module-at-a-time ('self.py_modules') or by whole packages ('self.packages'). Return a list of tuples (package, module, module_file), just like 'find_modules()' and 'find_package_modules()' do."""
bb7ab6f2da512ae49ba5305c52bfb2e3d073391c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bb7ab6f2da512ae49ba5305c52bfb2e3d073391c/build_py.py
if not port: port = SMTP_PORT
if not port: port = self.default_port
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
43a3b8327e6401a43e4e8f0b4d101646e5fb05ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/43a3b8327e6401a43e4e8f0b4d101646e5fb05ac/smtplib.py
self.sock = socket.socket(af, socktype, proto) if self.debuglevel > 0: print>>stderr, 'connect:', sa self.sock.connect(sa)
self._get_socket(af,socktype,proto,sa)
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
43a3b8327e6401a43e4e8f0b4d101646e5fb05ac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/43a3b8327e6401a43e4e8f0b4d101646e5fb05ac/smtplib.py
self.detect_ctypes()
self.detect_ctypes(inc_dirs, lib_dirs)
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
f46b1af583107a72f9eeb0b69a211a4c6a39d214 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f46b1af583107a72f9eeb0b69a211a4c6a39d214/setup.py
(srcdir,) = sysconfig.get_config_vars('srcdir') ffi_builddir = os.path.join(self.build_temp, 'libffi') ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi')) ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') if self.force or not os.path.exists(ffi_configfile): from distutils.dir_util import mkpath mkpath(ffi_builddir) config_args = [] cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ % (ffi_builddir, ffi_srcdir, " ".join(config_args)) res = os.system(cmd) if res or not os.path.exists(ffi_configfile): print "Failed to configure _ctypes module" return False fficonfig = {} execfile(ffi_configfile, globals(), fficonfig) ffi_srcdir = os.path.join(fficonfig['ffi_srcdir'], 'src') self.compiler.src_extensions.append('.S') include_dirs = [os.path.join(ffi_builddir, 'include'), ffi_builddir, ffi_srcdir] extra_compile_args = fficonfig['ffi_cflags'].split() ext.sources.extend(fficonfig['ffi_sources']) ext.include_dirs.extend(include_dirs) ext.extra_compile_args.extend(extra_compile_args)
if not self.use_system_libffi: (srcdir,) = sysconfig.get_config_vars('srcdir') ffi_builddir = os.path.join(self.build_temp, 'libffi') ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi')) ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') if self.force or not os.path.exists(ffi_configfile): from distutils.dir_util import mkpath mkpath(ffi_builddir) config_args = [] cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ % (ffi_builddir, ffi_srcdir, " ".join(config_args)) res = os.system(cmd) if res or not os.path.exists(ffi_configfile): print "Failed to configure _ctypes module" return False fficonfig = {} execfile(ffi_configfile, globals(), fficonfig) ffi_srcdir = os.path.join(fficonfig['ffi_srcdir'], 'src') self.compiler.src_extensions.append('.S') include_dirs = [os.path.join(ffi_builddir, 'include'), ffi_builddir, ffi_srcdir] extra_compile_args = fficonfig['ffi_cflags'].split() ext.sources.extend(fficonfig['ffi_sources']) ext.include_dirs.extend(include_dirs) ext.extra_compile_args.extend(extra_compile_args)
def configure_ctypes(self, ext): (srcdir,) = sysconfig.get_config_vars('srcdir') ffi_builddir = os.path.join(self.build_temp, 'libffi') ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi')) ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py')
f46b1af583107a72f9eeb0b69a211a4c6a39d214 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f46b1af583107a72f9eeb0b69a211a4c6a39d214/setup.py
def detect_ctypes(self):
def detect_ctypes(self, inc_dirs, lib_dirs): self.use_system_libffi = False
def detect_ctypes(self): include_dirs = [] extra_compile_args = [] sources = ['_ctypes/_ctypes.c', '_ctypes/callbacks.c', '_ctypes/callproc.c', '_ctypes/stgdict.c', '_ctypes/cfield.c', '_ctypes/malloc_closure.c'] depends = ['_ctypes/ctypes.h']
f46b1af583107a72f9eeb0b69a211a4c6a39d214 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f46b1af583107a72f9eeb0b69a211a4c6a39d214/setup.py
def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result)
def test_RFC1808(self): self.checkJoin(RFC1808_BASE, 'g:h', 'g:h') self.checkJoin(RFC1808_BASE, 'g', 'http://a/b/c/g') self.checkJoin(RFC1808_BASE, './g', 'http://a/b/c/g') self.checkJoin(RFC1808_BASE, 'g/', 'http://a/b/c/g/') self.checkJoin(RFC1808_BASE, '/g', 'http://a/g') self.checkJoin(RFC1808_BASE, '//g', 'http://g') self.checkJoin(RFC1808_BASE, '?y', 'http://a/b/c/d;p?y') self.checkJoin(RFC1808_BASE, 'g?y', 'http://a/b/c/g?y') self.checkJoin(RFC1808_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x') self.checkJoin(RFC1808_BASE, ' self.checkJoin(RFC1808_BASE, 'g self.checkJoin(RFC1808_BASE, 'g self.checkJoin(RFC1808_BASE, 'g?y self.checkJoin(RFC1808_BASE, ';x', 'http://a/b/c/d;x') self.checkJoin(RFC1808_BASE, 'g;x', 'http://a/b/c/g;x') self.checkJoin(RFC1808_BASE, 'g;x?y self.checkJoin(RFC1808_BASE, '.', 'http://a/b/c/') self.checkJoin(RFC1808_BASE, './', 'http://a/b/c/') self.checkJoin(RFC1808_BASE, '..', 'http://a/b/') self.checkJoin(RFC1808_BASE, '../', 'http://a/b/') self.checkJoin(RFC1808_BASE, '../g', 'http://a/b/g') self.checkJoin(RFC1808_BASE, '../..', 'http://a/') self.checkJoin(RFC1808_BASE, '../../', 'http://a/') self.checkJoin(RFC1808_BASE, '../../g', 'http://a/g')
def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result)
04c9ef91e7c57fade9621e010907d6605f3519e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/04c9ef91e7c57fade9621e010907d6605f3519e9/test_urlparse.py
print "urlparse.urljoin() tests" print
self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q self.checkJoin(RFC1808_BASE, '../../../g', 'http://a/../g') self.checkJoin(RFC1808_BASE, '../../../../g', 'http://a/../../g') self.checkJoin(RFC1808_BASE, '/./g', 'http://a/./g') self.checkJoin(RFC1808_BASE, '/../g', 'http://a/../g') self.checkJoin(RFC1808_BASE, 'g.', 'http://a/b/c/g.') self.checkJoin(RFC1808_BASE, '.g', 'http://a/b/c/.g') self.checkJoin(RFC1808_BASE, 'g..', 'http://a/b/c/g..') self.checkJoin(RFC1808_BASE, '..g', 'http://a/b/c/..g') self.checkJoin(RFC1808_BASE, './../g', 'http://a/b/g') self.checkJoin(RFC1808_BASE, './g/.', 'http://a/b/c/g/') self.checkJoin(RFC1808_BASE, 'g/./h', 'http://a/b/c/g/h') self.checkJoin(RFC1808_BASE, 'g/../h', 'http://a/b/c/h')
def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result)
04c9ef91e7c57fade9621e010907d6605f3519e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/04c9ef91e7c57fade9621e010907d6605f3519e9/test_urlparse.py
checkJoin('g:h', 'g:h') checkJoin('g', 'http://a/b/c/g') checkJoin('./g', 'http://a/b/c/g') checkJoin('g/', 'http://a/b/c/g/') checkJoin('/g', 'http://a/g') checkJoin('//g', 'http://g') checkJoin('?y', 'http://a/b/c/d;p?y') checkJoin('g?y', 'http://a/b/c/g?y') checkJoin('g?y/./x', 'http://a/b/c/g?y/./x') checkJoin(' checkJoin('g checkJoin('g checkJoin('g?y checkJoin(';x', 'http://a/b/c/d;x') checkJoin('g;x', 'http://a/b/c/g;x') checkJoin('g;x?y checkJoin('.', 'http://a/b/c/') checkJoin('./', 'http://a/b/c/') checkJoin('..', 'http://a/b/') checkJoin('../', 'http://a/b/') checkJoin('../g', 'http://a/b/g') checkJoin('../..', 'http://a/') checkJoin('../../', 'http://a/') checkJoin('../../g', 'http://a/g')
def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result)
04c9ef91e7c57fade9621e010907d6605f3519e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/04c9ef91e7c57fade9621e010907d6605f3519e9/test_urlparse.py
checkJoin('', 'http://a/b/c/d;p?q checkJoin('../../../g', 'http://a/../g') checkJoin('../../../../g', 'http://a/../../g') checkJoin('/./g', 'http://a/./g') checkJoin('/../g', 'http://a/../g') checkJoin('g.', 'http://a/b/c/g.') checkJoin('.g', 'http://a/b/c/.g') checkJoin('g..', 'http://a/b/c/g..') checkJoin('..g', 'http://a/b/c/..g') checkJoin('./../g', 'http://a/b/g') checkJoin('./g/.', 'http://a/b/c/g/') checkJoin('g/./h', 'http://a/b/c/g/h') checkJoin('g/../h', 'http://a/b/c/h')
def test_RFC2396(self):
def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result)
04c9ef91e7c57fade9621e010907d6605f3519e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/04c9ef91e7c57fade9621e010907d6605f3519e9/test_urlparse.py
def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result)
04c9ef91e7c57fade9621e010907d6605f3519e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/04c9ef91e7c57fade9621e010907d6605f3519e9/test_urlparse.py
print errors, "errors"
self.checkJoin(RFC2396_BASE, 'g:h', 'g:h') self.checkJoin(RFC2396_BASE, 'g', 'http://a/b/c/g') self.checkJoin(RFC2396_BASE, './g', 'http://a/b/c/g') self.checkJoin(RFC2396_BASE, 'g/', 'http://a/b/c/g/') self.checkJoin(RFC2396_BASE, '/g', 'http://a/g') self.checkJoin(RFC2396_BASE, '//g', 'http://g') self.checkJoin(RFC2396_BASE, 'g?y', 'http://a/b/c/g?y') self.checkJoin(RFC2396_BASE, ' self.checkJoin(RFC2396_BASE, 'g self.checkJoin(RFC2396_BASE, 'g?y self.checkJoin(RFC2396_BASE, 'g;x', 'http://a/b/c/g;x') self.checkJoin(RFC2396_BASE, 'g;x?y self.checkJoin(RFC2396_BASE, '.', 'http://a/b/c/') self.checkJoin(RFC2396_BASE, './', 'http://a/b/c/') self.checkJoin(RFC2396_BASE, '..', 'http://a/b/') self.checkJoin(RFC2396_BASE, '../', 'http://a/b/') self.checkJoin(RFC2396_BASE, '../g', 'http://a/b/g') self.checkJoin(RFC2396_BASE, '../..', 'http://a/') self.checkJoin(RFC2396_BASE, '../../', 'http://a/') self.checkJoin(RFC2396_BASE, '../../g', 'http://a/g') self.checkJoin(RFC2396_BASE, '', RFC2396_BASE) self.checkJoin(RFC2396_BASE, '../../../g', 'http://a/../g') self.checkJoin(RFC2396_BASE, '../../../../g', 'http://a/../../g') self.checkJoin(RFC2396_BASE, '/./g', 'http://a/./g') self.checkJoin(RFC2396_BASE, '/../g', 'http://a/../g') self.checkJoin(RFC2396_BASE, 'g.', 'http://a/b/c/g.') self.checkJoin(RFC2396_BASE, '.g', 'http://a/b/c/.g') self.checkJoin(RFC2396_BASE, 'g..', 'http://a/b/c/g..') self.checkJoin(RFC2396_BASE, '..g', 'http://a/b/c/..g') self.checkJoin(RFC2396_BASE, './../g', 'http://a/b/g') self.checkJoin(RFC2396_BASE, './g/.', 'http://a/b/c/g/') self.checkJoin(RFC2396_BASE, 'g/./h', 'http://a/b/c/g/h') self.checkJoin(RFC2396_BASE, 'g/../h', 'http://a/b/c/h') self.checkJoin(RFC2396_BASE, 'g;x=1/./y', 'http://a/b/c/g;x=1/y') self.checkJoin(RFC2396_BASE, 'g;x=1/../y', 'http://a/b/c/y') self.checkJoin(RFC2396_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x') self.checkJoin(RFC2396_BASE, 'g?y/../x', 'http://a/b/c/g?y/../x') self.checkJoin(RFC2396_BASE, 'g self.checkJoin(RFC2396_BASE, 'g def test_main(): test_support.run_unittest(UrlParseTestCase) if __name__ == "__main__": test_main()
def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result)
04c9ef91e7c57fade9621e010907d6605f3519e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/04c9ef91e7c57fade9621e010907d6605f3519e9/test_urlparse.py
self.bg="
self.bg="
def __init__(self,parent,title): Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.geometry("+%d+%d" % (parent.winfo_rootx()+30, parent.winfo_rooty()+30)) #elguavas - config placeholders til config stuff completed self.bg="#555555" self.fg="#ffffff" #no ugly bold default font on *nix font=tkFont.Font(self,Label().cget('font')) if os.name=='posix': font.config(weight=NORMAL) self.textFont=font self.CreateWidgets() self.resizable(height=FALSE,width=FALSE) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.buttonOk.focus_set() #key bindings for this dialog self.bind('<Alt-c>',self.CreditsButtonBinding) #credits button #self.bind('<Alt-l>',self.LicenseButtonBinding) #license button self.bind('<Alt-r>',self.LicenseButtonBinding) #readme button self.bind('<Return>',self.Ok) #dismiss dialog self.bind('<Escape>',self.Ok) #dismiss dialog self.wait_window()
67986778658bbabde2dbb739f2851c020fc9fe8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/67986778658bbabde2dbb739f2851c020fc9fe8f/aboutDialog.py
font=tkFont.Font(self,Label().cget('font'))
font=tkFont.Font(self,Label(self).cget('font'))
def __init__(self,parent,title): Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.geometry("+%d+%d" % (parent.winfo_rootx()+30, parent.winfo_rooty()+30)) #elguavas - config placeholders til config stuff completed self.bg="#555555" self.fg="#ffffff" #no ugly bold default font on *nix font=tkFont.Font(self,Label().cget('font')) if os.name=='posix': font.config(weight=NORMAL) self.textFont=font self.CreateWidgets() self.resizable(height=FALSE,width=FALSE) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.buttonOk.focus_set() #key bindings for this dialog self.bind('<Alt-c>',self.CreditsButtonBinding) #credits button #self.bind('<Alt-l>',self.LicenseButtonBinding) #license button self.bind('<Alt-r>',self.LicenseButtonBinding) #readme button self.bind('<Return>',self.Ok) #dismiss dialog self.bind('<Escape>',self.Ok) #dismiss dialog self.wait_window()
67986778658bbabde2dbb739f2851c020fc9fe8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/67986778658bbabde2dbb739f2851c020fc9fe8f/aboutDialog.py
self.bind('<Alt-r>',self.LicenseButtonBinding)
self.bind('<Alt-l>',self.LicenseButtonBinding)
def __init__(self,parent,title): Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.geometry("+%d+%d" % (parent.winfo_rootx()+30, parent.winfo_rooty()+30)) #elguavas - config placeholders til config stuff completed self.bg="#555555" self.fg="#ffffff" #no ugly bold default font on *nix font=tkFont.Font(self,Label().cget('font')) if os.name=='posix': font.config(weight=NORMAL) self.textFont=font self.CreateWidgets() self.resizable(height=FALSE,width=FALSE) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Ok) self.parent = parent self.buttonOk.focus_set() #key bindings for this dialog self.bind('<Alt-c>',self.CreditsButtonBinding) #credits button #self.bind('<Alt-l>',self.LicenseButtonBinding) #license button self.bind('<Alt-r>',self.LicenseButtonBinding) #readme button self.bind('<Return>',self.Ok) #dismiss dialog self.bind('<Escape>',self.Ok) #dismiss dialog self.wait_window()
67986778658bbabde2dbb739f2851c020fc9fe8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/67986778658bbabde2dbb739f2851c020fc9fe8f/aboutDialog.py
if __debug__ and self.debug >= 1: _mesg('new IMAP4 connection, tag=%s' % self.tagpre)
if __debug__: if self.debug >= 1: _mesg('new IMAP4 connection, tag=%s' % self.tagpre)
def __init__(self, host = '', port = IMAP4_PORT): self.host = host self.port = port self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_response = '' # Last continuation response self.tagnum = 0
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
def __init__(self, host = '', port = IMAP4_PORT): self.host = host self.port = port self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_response = '' # Last continuation response self.tagnum = 0
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and self.debug >= 3: _mesg('CAPABILITIES: %s' % `self.capabilities`)
if __debug__: if self.debug >= 3: _mesg('CAPABILITIES: %s' % `self.capabilities`)
def __init__(self, host = '', port = IMAP4_PORT): self.host = host self.port = port self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_response = '' # Last continuation response self.tagnum = 0
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
(typ, [data]) = <instance>.list(user, password) """ typ, dat = self._simple_command('LOGIN', user, password)
(typ, [data]) = <instance>.login(user, password) NB: 'password' will be quoted. """ typ, dat = self._simple_command('LOGIN', user, self._quote(password))
def login(self, user, password): """Identify client using plaintext password.
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and self.debug >= 3: _dump_ur(self.untagged_responses)
if __debug__: if self.debug >= 3: _dump_ur(self.untagged_responses)
def noop(self): """Send NOOP command.
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and self.debug >= 1: _dump_ur(self.untagged_responses)
if __debug__: if self.debug >= 1: _dump_ur(self.untagged_responses)
def select(self, mailbox='INBOX', readonly=None): """Select a mailbox.
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and self.debug >= 5: _mesg('untagged_responses[%s] %s += %s' % (typ, len(ur.get(typ,'')), dat))
if __debug__: if self.debug >= 5: _mesg('untagged_responses[%s] %s += ["%s"]' % (typ, len(ur.get(typ,'')), dat))
def _append_untagged(self, typ, dat):
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
for d in args: if d is None: continue if type(d) is type(''): l = len(string.split(d)) else: l = 1 if l == 0 or l > 1 and (d[0],d[-1]) not in (('(',')'),('"','"')): data = '%s "%s"' % (data, d) else: data = '%s %s' % (data, d)
for arg in args: if arg is None: continue data = '%s %s' % (data, self._checkquote(arg))
def _command(self, name, *args):
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and self.debug >= 4: _mesg('> %s' % data)
def _command(self, name, *args):
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and self.debug >= 4: _mesg('write literal size %s' % len(literal))
if __debug__: if self.debug >= 4: _mesg('write literal size %s' % len(literal))
def _command(self, name, *args):
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if self.untagged_responses.has_key('BYE') and name != 'LOGOUT': raise self.abort(self.untagged_responses['BYE'][-1])
self._check_bye()
def _command_complete(self, name, tag): try: typ, data = self._get_tagged_response(tag) except self.abort, val: raise self.abort('command: %s => %s' % (name, val)) except self.error, val: raise self.error('command: %s => %s' % (name, val)) if self.untagged_responses.has_key('BYE') and name != 'LOGOUT': raise self.abort(self.untagged_responses['BYE'][-1]) if typ == 'BAD': raise self.error('%s command error: %s %s' % (name, typ, data)) return typ, data
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and self.debug >= 4: _mesg('read literal size %s' % size)
if __debug__: if self.debug >= 4: _mesg('read literal size %s' % size)
def _get_response(self):
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and self.debug >= 1 and typ in ('NO', 'BAD'): _mesg('%s response: %s' % (typ, dat))
if __debug__: if self.debug >= 1 and typ in ('NO', 'BAD', 'BYE'): _mesg('%s response: %s' % (typ, dat))
def _get_response(self):
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and self.debug >= 4: _mesg('< %s' % line)
if __debug__: if self.debug >= 4: _mesg('< %s' % line) else: _log('< %s' % line)
def _get_line(self):
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and self.mo is not None and self.debug >= 5: _mesg("\tmatched r'%s' => %s" % (cre.pattern, `self.mo.groups()`))
if __debug__: if self.mo is not None and self.debug >= 5: _mesg("\tmatched r'%s' => %s" % (cre.pattern, `self.mo.groups()`))
def _match(self, cre, s):
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and self.debug >= 5: _mesg('untagged_responses[%s] => %s' % (name, data))
if __debug__: if self.debug >= 5: _mesg('untagged_responses[%s] => %s' % (name, data))
def _untagged_response(self, typ, dat, name):
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if dttype is type(1):
if dttype is type(1) or dttype is type(1.1):
def Time2Internaldate(date_time): """Convert 'date_time' to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"' """ dttype = type(date_time) if dttype is type(1): tt = time.localtime(date_time) elif dttype is type(()): tt = date_time elif dttype is type(""): return date_time # Assume in correct format else: raise ValueError dt = time.strftime("%d-%b-%Y %H:%M:%S", tt) if dt[0] == '0': dt = ' ' + dt[1:] if time.daylight and tt[-1]: zone = -time.altzone else: zone = -time.timezone return '"' + dt + " %+02d%02d" % divmod(zone/60, 60) + '"'
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
def _mesg(s): sys.stderr.write('\t'+s+'\n')
def _mesg(s, secs=None): if secs is None: secs = time.time() tm = time.strftime('%M:%S', time.localtime(secs)) sys.stderr.write(' %s.%02d %s\n' % (tm, (secs*100)%100, s))
def _mesg(s):
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
if __debug__ and __name__ == '__main__':
_cmd_log = [] _cmd_log_len = 10 def _log(line): if len(_cmd_log) == _cmd_log_len: del _cmd_log[0] _cmd_log.append((time.time(), line)) def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs) if __name__ == '__main__':
def _dump_ur(dict): # Dump untagged responses (in `dict'). l = dict.items() if not l: return t = '\n\t\t' j = string.join l = map(lambda x,j=j:'%s: "%s"' % (x[0], x[1][0] and j(x[1], '" "') or ''), l) _mesg('untagged responses dump:%s%s' % (t, j(l, t)))
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
_mesg(' %s %s\n => %s %s' % (cmd, args, typ, dat))
_mesg('%s => %s %s' % (cmd, typ, dat))
def run(cmd, args): typ, dat = apply(eval('M.%s' % cmd), args) _mesg(' %s %s\n => %s %s' % (cmd, args, typ, dat)) return dat
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
uid = string.split(dat[-1])[-1] run('uid', ('FETCH', '%s' % uid,
uid = string.split(dat[-1]) if not uid: continue run('uid', ('FETCH', '%s' % uid[-1],
def run(cmd, args): typ, dat = apply(eval('M.%s' % cmd), args) _mesg(' %s %s\n => %s %s' % (cmd, args, typ, dat)) return dat
b7ea8daca8563042c122b826472f3e45d15d1c52 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7ea8daca8563042c122b826472f3e45d15d1c52/imaplib.py
elif sys.version < '2.1': if sys.platform == 'aix4': python_lib = get_python_lib(standard_lib=1) ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) elif sys.platform == 'beos': python_lib = get_python_lib(standard_lib=1) linkerscript_name = os.path.basename(string.split(g['LDSHARED'])[0]) linkerscript = os.path.join(python_lib, 'config', linkerscript_name) g['LDSHARED'] = ("%s -L%s/lib -lpython%s" % (linkerscript, PREFIX, sys.version[0:3]))
def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" g = {} # load the installed Makefile: try: filename = get_makefile_filename() parse_makefile(filename, g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): my_msg = my_msg + " (%s)" % msg.strerror raise DistutilsPlatformError(my_msg) # On AIX, there are wrong paths to the linker scripts in the Makefile # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. if python_build: g['LDSHARED'] = g['BLDSHARED'] global _config_vars _config_vars = g
b7943b002c925ccae2ef33d4c1df0e1e03945fd6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b7943b002c925ccae2ef33d4c1df0e1e03945fd6/sysconfig.py
(fd, name) = tempfile.mkstemp(suffix=['.html', '.txt'][text],
(fd, path) = tempfile.mkstemp(suffix=['.html', '.txt'][text],
def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset())
38cde6ffbf72d812563c017a42a3b38260fc3979 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/38cde6ffbf72d812563c017a42a3b38260fc3979/cgitb.py
except AttributeError: pass else: raise TestFailed, 'expected AttributeError' if b.__dict__ <> None: raise TestFailed, 'expected unassigned func.__dict__ to be None'
except AttributeError: pass else: raise TestFailed, 'expected AttributeError' if b.__dict__ <> {}: raise TestFailed, 'expected unassigned func.__dict__ to be {}'
def b(): 'my docstring' pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
del b.__dict__ if b.__dict__ <> None: raise TestFailed, 'del func.__dict__ did not result in __dict__ == None'
try: del b.__dict__ except TypeError: pass else: raise TestFailed, 'del func.__dict__ expected TypeError'
def b(): 'my docstring' pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
b.__dict__ = None if b.__dict__ <> None: raise TestFailed, 'func.__dict__ = None did not result in __dict__ == None'
try: b.__dict__ = None except TypeError: pass else: raise TestFailed, 'func.__dict__ = None expected TypeError' d = {'hello': 'world'} b.__dict__ = d if b.func_dict is not d: raise TestFailed, 'func.__dict__ assignment to dictionary failed' if b.hello <> 'world': raise TestFailed, 'attribute after func.__dict__ assignment failed'
def b(): 'my docstring' pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
except AttributeError: pass else: raise TestFailed, 'expected AttributeError'
except AttributeError: pass else: raise TestFailed, 'expected AttributeError'
def b(): 'my docstring' pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
except AttributeError: pass else: raise TestFailed, 'expected AttributeError'
except AttributeError: pass else: raise TestFailed, 'expected AttributeError'
def b(): 'my docstring' pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
except TypeError: pass else: raise TestFailed, 'expected TypeError'
except TypeError: pass else: raise TestFailed, 'expected TypeError'
def b(): 'my docstring' pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
except TypeError: pass else: raise TestFailed, 'expected TypeError'
except TypeError: pass else: raise TestFailed, 'expected TypeError'
def b(): 'my docstring' pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
except TypeError: pass else: raise TestFailed, 'expected TypeError'
except TypeError: pass else: raise TestFailed, 'expected TypeError'
def b(): 'my docstring' pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
f1.a.myclass is not F.a.myclass:
f1.a.myclass is not F.a.myclass:
def b(): 'my docstring' pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
except TypeError: pass else: raise TestFailed, 'expected TypeError'
except TypeError: pass else: raise TestFailed, 'expected TypeError'
def b(): 'my docstring' pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
except TypeError: pass else: raise TestFailed
except TypeError: pass else: raise TestFailed
def b(): 'my docstring' pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
del another.__dict__ del another.func_dict another.func_dict = None
try: del another.__dict__ except TypeError: pass else: raise TestFailed try: del another.func_dict except TypeError: pass else: raise TestFailed try: another.func_dict = None except TypeError: pass else: raise TestFailed
def another(): pass
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
if foo==bar: raise TestFailed
if foo==bar: raise TestFailed
def temp(): print 1
19490fcd3650b91ff20afbec3aad3295d3ad9ccd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/19490fcd3650b91ff20afbec3aad3295d3ad9ccd/test_funcattrs.py
self.tagpre = Int2AP(random.randint(0, 31999))
self.tagpre = Int2AP(random.randint(4096, 65535))
def __init__(self, host = '', port = IMAP4_PORT): self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_response = '' # Last continuation response self.is_readonly = None # READ-ONLY desired state self.tagnum = 0
4cfdb154409f2529cb16bcb2638b047cc632a3ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4cfdb154409f2529cb16bcb2638b047cc632a3ec/imaplib.py
msgbuf = ""
msgbuf = []
def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket.
dda7741de7f788964931d8179b1cc1d9a81194cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/dda7741de7f788964931d8179b1cc1d9a81194cb/httplib.py
msgbuf = msgbuf + self.__ssl.read()
buf = self.__ssl.read()
def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket.
dda7741de7f788964931d8179b1cc1d9a81194cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/dda7741de7f788964931d8179b1cc1d9a81194cb/httplib.py
return StringIO(msgbuf)
if buf == '': break msgbuf.append(buf) return StringIO("".join(msgbuf))
def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket.
dda7741de7f788964931d8179b1cc1d9a81194cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/dda7741de7f788964931d8179b1cc1d9a81194cb/httplib.py
self.assertEqual(re.match('(x)*', 50000*'x').span(), (0, 50000))
try: re.match('(x)*', 50000*'x') except RuntimeError, v: self.assertEqual(str(v), "maximum recursion limit exceeded") else: self.fail("re.match('(x)*', 50000*'x') should have failed")
def test_limitations(self): # Try nasty case that overflows the straightforward recursive # implementation of repeated groups. self.assertEqual(re.match('(x)*', 50000*'x').span(), (0, 50000))
79ee0feec0575f93c25781283f5925254a8cc6c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/79ee0feec0575f93c25781283f5925254a8cc6c6/test_re.py
if not ':' in head:
if os.sep == ':' and not ':' in head:
def mkdirs(dst): """Make directories leading to 'dst' if they don't exist yet""" if dst == '' or os.path.exists(dst): return head, tail = os.path.split(dst) if not ':' in head: head = head + ':' mkdirs(head) os.mkdir(dst, 0777)
778212da692261010c0cdbf6c7171ef743511047 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/778212da692261010c0cdbf6c7171ef743511047/macostools.py
WalkTests
WalkTests, MakedirTests,
def test_main(): test_support.run_unittest( TemporaryFileTests, StatAttributeTests, EnvironTests, WalkTests )
f6579c7f0d79550f658bbcf71fdea85aa0af7a27 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f6579c7f0d79550f658bbcf71fdea85aa0af7a27/test_os.py
"""retrieve(url) returns (filename, None) for a local object
"""retrieve(url) returns (filename, headers) for a local object
def retrieve(self, url, filename=None, reporthook=None, data=None): """retrieve(url) returns (filename, None) for a local object or (tempfilename, headers) for a remote object.""" url = unwrap(toBytes(url)) if self.tempcache and url in self.tempcache: return self.tempcache[url] type, url1 = splittype(url) if filename is None and (not type or type == 'file'): try: fp = self.open_local_file(url1) hdrs = fp.info() del fp return url2pathname(splithost(url1)[1]), hdrs except IOError, msg: pass fp = self.open(url, data) headers = fp.info() if filename: tfp = open(filename, 'wb') else: import tempfile garbage, path = splittype(url) garbage, path = splithost(path or "") path, garbage = splitquery(path or "") path, garbage = splitattr(path or "") suffix = os.path.splitext(path)[1] (fd, filename) = tempfile.mkstemp(suffix) self.__tempfiles.append(filename) tfp = os.fdopen(fd, 'wb') result = filename, headers if self.tempcache is not None: self.tempcache[url] = result bs = 1024*8 size = -1 blocknum = 1 if reporthook: if "content-length" in headers: size = int(headers["Content-Length"]) reporthook(0, bs, size) block = fp.read(bs) if reporthook: reporthook(1, bs, size) while block: tfp.write(block) block = fp.read(bs) blocknum = blocknum + 1 if reporthook: reporthook(blocknum, bs, size) fp.close() tfp.close() del fp del tfp return result
acc72d20d70537407eefb66520ee199806098095 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/acc72d20d70537407eefb66520ee199806098095/urllib.py
'DocTestTestFailure',
>>> def f(x):
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
def _utest(tester, name, doc, filename, lineno): import sys from StringIO import StringIO old = sys.stdout sys.stdout = new = StringIO() try: failures, tries = tester.runstring(doc, name) finally: sys.stdout = old if failures: msg = new.getvalue() lname = '.'.join(name.split('.')[-1:]) if not lineno: lineno = "0 (don't know line number)" raise DocTestTestFailure('Failed doctest test for %s\n' ' File "%s", line %s, in %s\n\n%s' % (name, filename, lineno, lname, msg)) class DocTestTestFailure(Exception): """A doctest test failed""" def DocTestSuite(module=None): """Convert doctest tests for a module to a unittest TestSuite. The returned TestSuite is to be run by the unittest framework, and runs each doctest in the module. If any of the doctests fail, then the synthesized unit test fails, and an error is raised showing the name of the file containing the test and a (sometimes approximate) line number. The optional module argument provides the module to be tested. It can be a module object or a (possibly dotted) module name. If not specified, the module calling DocTestSuite() is used. Example (although note that unittest supplies many ways to use the TestSuite returned; see the unittest docs): import unittest import doctest import my_module_with_doctests suite = doctest.DocTestSuite(my_module_with_doctests) runner = unittest.TextTestRunner() runner.run(suite)
from StringIO import StringIO import os import sys import tempfile import unittest class DocTestTestCase(unittest.TestCase): """A test case that wraps a test function. This is useful for slipping pre-existing test functions into the PyUnit framework. Optionally, set-up and tidy-up functions can be supplied. As with TestCase, the tidy-up ('tearDown') function will always be called if the set-up ('setUp') function ran successfully.
def _find_tests(module, prefix=None): if prefix is None: prefix = module.__name__ mdict = module.__dict__ tests = [] # Get the module-level doctest (if any). _get_doctest(prefix, module, tests, '', lineno="1 (or above)") # Recursively search the module __dict__ for doctests. if prefix: prefix += "." _extract_doctests(mdict.items(), module, mdict, tests, prefix) return tests
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
import unittest module = _normalize_module(module) tests = _find_tests(module)
def __init__(self, tester, name, doc, filename, lineno, setUp=None, tearDown=None): unittest.TestCase.__init__(self) (self.__tester, self.__name, self.__doc, self.__filename, self.__lineno, self.__setUp, self.__tearDown ) = tester, name, doc, filename, lineno, setUp, tearDown def setUp(self): if self.__setUp is not None: self.__setUp() def tearDown(self): if self.__tearDown is not None: self.__tearDown() def runTest(self): old = sys.stdout new = StringIO() try: sys.stdout = new failures, tries = self.__tester.runstring(self.__doc, self.__name) finally: sys.stdout = old if failures: lname = '.'.join(self.__name.split('.')[-1:]) lineno = self.__lineno or "0 (don't know line no)" raise self.failureException( 'Failed doctest test for %s\n' ' File "%s", line %s, in %s\n\n%s' % (self.__name, self.__filename, lineno, lname, new.getvalue()) ) def id(self): return self.__name def __repr__(self): name = self.__name.split('.') return "%s (%s)" % (name[-1], '.'.join(name[:-1])) __str__ = __repr__ def shortDescription(self): return "Doctest: " + self.__name def DocTestSuite(module=None, setUp=lambda: None, tearDown=lambda: None, ): """Convert doctest tests for a mudule to a unittest test suite This tests convers each documentation string in a module that contains doctest tests to a unittest test case. If any of the tests in a doc string fail, then the test case fails. An error is raised showing the name of the file containing the test and a (sometimes approximate) line number. A module argument provides the module to be tested. The argument can be either a module or a module name. If no argument is given, the calling module is used. """ module = _normalizeModule(module) tests = _findTests(module)
def DocTestSuite(module=None): """Convert doctest tests for a module to a unittest TestSuite. The returned TestSuite is to be run by the unittest framework, and runs each doctest in the module. If any of the doctests fail, then the synthesized unit test fails, and an error is raised showing the name of the file containing the test and a (sometimes approximate) line number. The optional module argument provides the module to be tested. It can be a module object or a (possibly dotted) module name. If not specified, the module calling DocTestSuite() is used. Example (although note that unittest supplies many ways to use the TestSuite returned; see the unittest docs): import unittest import doctest import my_module_with_doctests suite = doctest.DocTestSuite(my_module_with_doctests) runner = unittest.TextTestRunner() runner.run(suite) """ import unittest module = _normalize_module(module) tests = _find_tests(module) if not tests: raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() tester = Tester(module) for name, doc, filename, lineno in tests: if not filename: filename = module.__file__ if filename.endswith(".pyc"): filename = filename[:-1] elif filename.endswith(".pyo"): filename = filename[:-1] def runit(name=name, doc=doc, filename=filename, lineno=lineno): _utest(tester, name, doc, filename, lineno) suite.addTest(unittest.FunctionTestCase( runit, description="doctest of " + name)) return suite
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
def runit(name=name, doc=doc, filename=filename, lineno=lineno): _utest(tester, name, doc, filename, lineno) suite.addTest(unittest.FunctionTestCase( runit, description="doctest of " + name))
suite.addTest(DocTestTestCase( tester, name, doc, filename, lineno, setUp, tearDown))
def runit(name=name, doc=doc, filename=filename, lineno=lineno): _utest(tester, name, doc, filename, lineno)
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
def _normalizeModule(module): if module is None: module = sys._getframe(2).f_globals['__name__'] module = sys.modules[module] elif isinstance(module, (str, unicode)): module = __import__(module, globals(), locals(), ["*"]) return module def _doc(name, object, tests, prefix, filename='', lineno=''): doc = getattr(object, '__doc__', '') if doc and doc.find('>>>') >= 0: tests.append((prefix+name, doc, filename, lineno)) def _findTests(module, prefix=None): if prefix is None: prefix = module.__name__ dict = module.__dict__ tests = [] _doc(prefix, module, tests, '', lineno="1 (or below)") prefix = prefix and (prefix + ".") _find(dict.items(), module, dict, tests, prefix) return tests def _find(items, module, dict, tests, prefix, minlineno=0): for name, object in items: if not hasattr(object, '__name__'): continue if hasattr(object, 'func_globals'): if object.func_globals is not dict: continue code = getattr(object, 'func_code', None) filename = getattr(code, 'co_filename', '') lineno = getattr(code, 'co_firstlineno', -1) + 1 if minlineno: minlineno = min(lineno, minlineno) else: minlineno = lineno _doc(name, object, tests, prefix, filename, lineno) elif hasattr(object, "__module__"): if object.__module__ != module.__name__: continue if not (hasattr(object, '__dict__') and hasattr(object, '__bases__')): continue lineno = _find(object.__dict__.items(), module, dict, tests, prefix+name+".") _doc(name, object, tests, prefix, lineno="%s (or above)" % (lineno-3)) return minlineno
def runit(name=name, doc=doc, filename=filename, lineno=lineno): _utest(tester, name, doc, filename, lineno)
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
def _expect(expect): # Return the expected output (if any), formatted as a Python # comment block. if expect: expect = "\n# ".join(expect.split("\n")) expect = "\n# Expect:\n# %s" % expect return expect
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
"""Extract the doctest examples from a docstring.
"""Extract the test sources from a doctest test docstring as a script
def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string containing Python code. The expected output blocks in the examples are converted to Python comments. """ module = _normalize_module(module) tests = _find_tests(module, "") test = [doc for (tname, doc, dummy, dummy) in tests if tname == name] if not test: raise ValueError(name, "not found in tests") test = test[0] examples = [source + _expect(expect) for source, expect, dummy in _extract_examples(test)] return '\n'.join(examples)
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string containing Python code. The expected output blocks in the examples are converted to Python comments.
test to be debugged and the name (within the module) of the object with the doc string with tests to be debugged.
def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string containing Python code. The expected output blocks in the examples are converted to Python comments. """ module = _normalize_module(module) tests = _find_tests(module, "") test = [doc for (tname, doc, dummy, dummy) in tests if tname == name] if not test: raise ValueError(name, "not found in tests") test = test[0] examples = [source + _expect(expect) for source, expect, dummy in _extract_examples(test)] return '\n'.join(examples)
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
module = _normalize_module(module) tests = _find_tests(module, "") test = [doc for (tname, doc, dummy, dummy) in tests if tname == name]
module = _normalizeModule(module) tests = _findTests(module, "") test = [doc for (tname, doc, f, l) in tests if tname == name]
def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string containing Python code. The expected output blocks in the examples are converted to Python comments. """ module = _normalize_module(module) tests = _find_tests(module, "") test = [doc for (tname, doc, dummy, dummy) in tests if tname == name] if not test: raise ValueError(name, "not found in tests") test = test[0] examples = [source + _expect(expect) for source, expect, dummy in _extract_examples(test)] return '\n'.join(examples)
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
examples = [source + _expect(expect) for source, expect, dummy in _extract_examples(test)] return '\n'.join(examples) def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and written to a temp file. The Python debugger (pdb) is then invoked on that file.
examples = _extract_examples(test) testsrc = '\n'.join([ "%s%s" % (source, _expect(expect)) for (source, expect, lineno) in examples ]) return testsrc def debug_src(src, pm=False, globs=None): """Debug a single doctest test doc string The string is provided directly
def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string containing Python code. The expected output blocks in the examples are converted to Python comments. """ module = _normalize_module(module) tests = _find_tests(module, "") test = [doc for (tname, doc, dummy, dummy) in tests if tname == name] if not test: raise ValueError(name, "not found in tests") test = test[0] examples = [source + _expect(expect) for source, expect, dummy in _extract_examples(test)] return '\n'.join(examples)
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
import os
examples = _extract_examples(src) src = '\n'.join([ "%s%s" % (source, _expect(expect)) for (source, expect, lineno) in examples ]) debug_script(src, pm, globs) def debug_script(src, pm=False, globs=None): "Debug a test script"
def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and written to a temp file. The Python debugger (pdb) is then invoked on that file. """ import os import pdb import tempfile module = _normalize_module(module) testsrc = testsource(module, name) srcfilename = tempfile.mktemp("doctestdebug.py") f = file(srcfilename, 'w') f.write(testsrc) f.close() globs = {} globs.update(module.__dict__) try: # Note that %r is vital here. '%s' instead can, e.g., cause # backslashes to get treated as metacharacters on Windows. pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: os.remove(srcfilename)
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
import tempfile module = _normalize_module(module) testsrc = testsource(module, name)
def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and written to a temp file. The Python debugger (pdb) is then invoked on that file. """ import os import pdb import tempfile module = _normalize_module(module) testsrc = testsource(module, name) srcfilename = tempfile.mktemp("doctestdebug.py") f = file(srcfilename, 'w') f.write(testsrc) f.close() globs = {} globs.update(module.__dict__) try: # Note that %r is vital here. '%s' instead can, e.g., cause # backslashes to get treated as metacharacters on Windows. pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: os.remove(srcfilename)
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
f = file(srcfilename, 'w') f.write(testsrc) f.close() globs = {} globs.update(module.__dict__)
open(srcfilename, 'w').write(src) if globs: globs = globs.copy() else: globs = {}
def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and written to a temp file. The Python debugger (pdb) is then invoked on that file. """ import os import pdb import tempfile module = _normalize_module(module) testsrc = testsource(module, name) srcfilename = tempfile.mktemp("doctestdebug.py") f = file(srcfilename, 'w') f.write(testsrc) f.close() globs = {} globs.update(module.__dict__) try: # Note that %r is vital here. '%s' instead can, e.g., cause # backslashes to get treated as metacharacters on Windows. pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: os.remove(srcfilename)
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
pdb.run("execfile(%r)" % srcfilename, globs, globs)
if pm: try: execfile(srcfilename, globs, globs) except: print sys.exc_info()[1] pdb.post_mortem(sys.exc_info()[2]) else: pdb.run("execfile(%r)" % srcfilename, globs, globs)
def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and written to a temp file. The Python debugger (pdb) is then invoked on that file. """ import os import pdb import tempfile module = _normalize_module(module) testsrc = testsource(module, name) srcfilename = tempfile.mktemp("doctestdebug.py") f = file(srcfilename, 'w') f.write(testsrc) f.close() globs = {} globs.update(module.__dict__) try: # Note that %r is vital here. '%s' instead can, e.g., cause # backslashes to get treated as metacharacters on Windows. pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: os.remove(srcfilename)
1323871f770a1332c44031c18abe670abdf6c641 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1323871f770a1332c44031c18abe670abdf6c641/doctest.py
text = editwin.text text.bind("<<run-module>>", self.run_module) text.bind("<<run-script>>", self.run_script) text.bind("<<new-shell>>", self.new_shell)
self.flist = self.editwin.flist self.root = self.flist.root
def __init__(self, editwin): self.editwin = editwin text = editwin.text text.bind("<<run-module>>", self.run_module) text.bind("<<run-script>>", self.run_script) text.bind("<<new-shell>>", self.new_shell)
fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5/ScriptBinding.py
def run_module(self, event=None):
def run_module_event(self, event, debugger=None): if not self.editwin.get_saved(): tkMessageBox.showerror("Not saved", "Please save first!", master=self.editwin.text) self.editwin.text.focus_set() return
def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module(modname) sys.modules[modname] = mod source = self.editwin.text.get("1.0", "end") exec source in mod.__dict__
fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5/ScriptBinding.py
try:
if sys.modules.has_key(modname):
def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module(modname) sys.modules[modname] = mod source = self.editwin.text.get("1.0", "end") exec source in mod.__dict__
fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5/ScriptBinding.py
except KeyError:
else:
def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module(modname) sys.modules[modname] = mod source = self.editwin.text.get("1.0", "end") exec source in mod.__dict__
fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5/ScriptBinding.py
source = self.editwin.text.get("1.0", "end") exec source in mod.__dict__
mod.__file__ = filename saveout = sys.stdout saveerr = sys.stderr owin = OnDemandOutputWindow(self.editwin.flist) try: sys.stderr = PseudoFile(owin, "stderr") try: sys.stdout = PseudoFile(owin, "stdout") try: if debugger: debugger.run("execfile(%s)" % `filename`, mod.__dict__) else: execfile(filename, mod.__dict__) except: (sys.last_type, sys.last_value, sys.last_traceback) = sys.exc_info() if not debugger: from StackViewer import StackBrowser sv = StackBrowser(self.root, self.flist) finally: sys.stdout = saveout finally: sys.stderr = saveerr
def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module(modname) sys.modules[modname] = mod source = self.editwin.text.get("1.0", "end") exec source in mod.__dict__
fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5/ScriptBinding.py
def run_script(self, event=None):
def debug_module_event(self, event): import Debugger debugger = Debugger.Debugger(self) self.run_module_event(event, debugger) def close_debugger(self):
def run_script(self, event=None): pass
fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5/ScriptBinding.py
def new_shell(self, event=None): import PyShell pyshell = PyShell.PyShell(self.editwin.flist) pyshell.begin()
def run_script(self, event=None): pass
fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa33935d8c7da182d7f2ddc8a19b8d44abfb9ef5/ScriptBinding.py
self.check_extension_list()
self.check_extensions_list(self.extensions)
def get_source_files (self): self.check_extension_list() filenames = []
f127683952996a7ba19a7678aa2e0572ee99ecf5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f127683952996a7ba19a7678aa2e0572ee99ecf5/build_ext.py
if startupinfo == None: startupinfo = STARTUPINFO() if not None in (p2cread, c2pwrite, errwrite): startupinfo.dwFlags |= STARTF_USESTDHANDLES startupinfo.hStdInput = p2cread startupinfo.hStdOutput = c2pwrite startupinfo.hStdError = errwrite
def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)"""
d796e455f2c81a3835f86b0ca169a4f8e761188b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d796e455f2c81a3835f86b0ca169a4f8e761188b/subprocess.py
raise TestFailed, "NotImplemented should have caused TypeErrpr"
raise TestFailed, "NotImplemented should have caused TypeError"
def __add__(self, other): return NotImplemented
2a1cec5b8d62515a61a486213ed30013236baa82 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2a1cec5b8d62515a61a486213ed30013236baa82/test_descr.py
t = threading.Thread(target = self.finish_request,
t = threading.Thread(target = self.process_request_thread,
def process_request(self, request, client_address): """Start a new thread to process the request.""" import threading t = threading.Thread(target = self.finish_request, args = (request, client_address)) t.start()
d60b5000ee7b27e8d78d93f7d2143e3d5d86a7cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d60b5000ee7b27e8d78d93f7d2143e3d5d86a7cb/SocketServer.py
exec('def f(a, a): pass')
exec 'def f(a, a): pass'
exec('def f(a, a): pass')
476ff493edf892ecabe3a51d0f4793092716ed4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/476ff493edf892ecabe3a51d0f4793092716ed4a/test_compile.py
exec('def f(a = 0, a = 1): pass')
exec 'def f(a = 0, a = 1): pass'
exec('def f(a = 0, a = 1): pass')
476ff493edf892ecabe3a51d0f4793092716ed4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/476ff493edf892ecabe3a51d0f4793092716ed4a/test_compile.py
exec('def f(a): global a; a = 1')
exec 'def f(a): global a; a = 1'
exec('def f(a): global a; a = 1')
476ff493edf892ecabe3a51d0f4793092716ed4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/476ff493edf892ecabe3a51d0f4793092716ed4a/test_compile.py
return '%s/%s' % (str(self.__num), str(self.__den))
return '(%s/%s)' % (str(self.__num), str(self.__den))
def __str__(self): if self.__den == 1: return str(self.__num) else: return '%s/%s' % (str(self.__num), str(self.__den))
71d3aa186579a353a324f0dac9b41910b16f0d16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/71d3aa186579a353a324f0dac9b41910b16f0d16/Rat.py
diff = a - b
diff = Rat(a - b)
def __cmp__(a, b): diff = a - b if diff.__num < 0: return -1 elif diff.__num > 0: return 1 else: return 0
71d3aa186579a353a324f0dac9b41910b16f0d16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/71d3aa186579a353a324f0dac9b41910b16f0d16/Rat.py
11/10 11/10
(11/10) (11/10)
def test(): '''\ Test function for rat module. The expected output is (module some differences in floating precission): -1 -1 0 0L 0.1 (0.1+0j) [Rat(1,2), Rat(-3,10), Rat(1,25), Rat(1,4)] [Rat(-3,10), Rat(1,25), Rat(1,4), Rat(1,2)] 0 11/10 11/10 1.1 OK 2 1.5 3/2 (1.5+1.5j) 15707963/5000000 2 2 2.0 (2+0j) 4 0 4 1 4 0 3.5 0.5 3.0 1.33333333333 2.82842712475 1 7/2 1/2 3 4/3 2.82842712475 1 (3.5+1.5j) (0.5-1.5j) (3+3j) (0.666666666667-0.666666666667j) (1.43248815986+2.43884761145j) 1 1.5 1 1.5 (1.5+0j) 3.5 -0.5 3.0 0.75 2.25 -1 3.0 0.0 2.25 1.0 1.83711730709 0 3.0 0.0 2.25 1.0 1.83711730709 1 (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1 3/2 1 1.5 (1.5+0j) 7/2 -1/2 3 3/4 9/4 -1 3.0 0.0 2.25 1.0 1.83711730709 -1 3 0 9/4 1 1.83711730709 0 (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1 (1.5+1.5j) (1.5+1.5j) (3.5+1.5j) (-0.5+1.5j) (3+3j) (0.75+0.75j) 4.5j -1 (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1 (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1 (3+3j) 0j 4.5j (1+0j) (-0.638110484918+0.705394566962j) 0 ''' print rat(-1L, 1) print rat(1, -1) a = rat(1, 10) print int(a), long(a), float(a), complex(a) b = rat(2, 5) l = [a+b, a-b, a*b, a/b] print l l.sort() print l print rat(0, 1) print a+1 print a+1L print a+1.0 try: print rat(1, 0) raise SystemError, 'should have been ZeroDivisionError' except ZeroDivisionError: print 'OK' print rat(2), rat(1.5), rat(3, 2), rat(1.5+1.5j), rat(31415926,10000000) list = [2, 1.5, rat(3,2), 1.5+1.5j] for i in list: print i, if type(i) is not ComplexType: print int(i), float(i), print complex(i) print for j in list: print i + j, i - j, i * j, i / j, i ** j, cmp(i, j)
71d3aa186579a353a324f0dac9b41910b16f0d16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/71d3aa186579a353a324f0dac9b41910b16f0d16/Rat.py
2 1.5 3/2 (1.5+1.5j) 15707963/5000000
2 1.5 (3/2) (1.5+1.5j) (15707963/5000000)
def test(): '''\ Test function for rat module. The expected output is (module some differences in floating precission): -1 -1 0 0L 0.1 (0.1+0j) [Rat(1,2), Rat(-3,10), Rat(1,25), Rat(1,4)] [Rat(-3,10), Rat(1,25), Rat(1,4), Rat(1,2)] 0 11/10 11/10 1.1 OK 2 1.5 3/2 (1.5+1.5j) 15707963/5000000 2 2 2.0 (2+0j) 4 0 4 1 4 0 3.5 0.5 3.0 1.33333333333 2.82842712475 1 7/2 1/2 3 4/3 2.82842712475 1 (3.5+1.5j) (0.5-1.5j) (3+3j) (0.666666666667-0.666666666667j) (1.43248815986+2.43884761145j) 1 1.5 1 1.5 (1.5+0j) 3.5 -0.5 3.0 0.75 2.25 -1 3.0 0.0 2.25 1.0 1.83711730709 0 3.0 0.0 2.25 1.0 1.83711730709 1 (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1 3/2 1 1.5 (1.5+0j) 7/2 -1/2 3 3/4 9/4 -1 3.0 0.0 2.25 1.0 1.83711730709 -1 3 0 9/4 1 1.83711730709 0 (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1 (1.5+1.5j) (1.5+1.5j) (3.5+1.5j) (-0.5+1.5j) (3+3j) (0.75+0.75j) 4.5j -1 (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1 (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1 (3+3j) 0j 4.5j (1+0j) (-0.638110484918+0.705394566962j) 0 ''' print rat(-1L, 1) print rat(1, -1) a = rat(1, 10) print int(a), long(a), float(a), complex(a) b = rat(2, 5) l = [a+b, a-b, a*b, a/b] print l l.sort() print l print rat(0, 1) print a+1 print a+1L print a+1.0 try: print rat(1, 0) raise SystemError, 'should have been ZeroDivisionError' except ZeroDivisionError: print 'OK' print rat(2), rat(1.5), rat(3, 2), rat(1.5+1.5j), rat(31415926,10000000) list = [2, 1.5, rat(3,2), 1.5+1.5j] for i in list: print i, if type(i) is not ComplexType: print int(i), float(i), print complex(i) print for j in list: print i + j, i - j, i * j, i / j, i ** j, cmp(i, j)
71d3aa186579a353a324f0dac9b41910b16f0d16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/71d3aa186579a353a324f0dac9b41910b16f0d16/Rat.py
7/2 1/2 3 4/3 2.82842712475 1
(7/2) (1/2) 3 (4/3) 2.82842712475 1
def test(): '''\ Test function for rat module. The expected output is (module some differences in floating precission): -1 -1 0 0L 0.1 (0.1+0j) [Rat(1,2), Rat(-3,10), Rat(1,25), Rat(1,4)] [Rat(-3,10), Rat(1,25), Rat(1,4), Rat(1,2)] 0 11/10 11/10 1.1 OK 2 1.5 3/2 (1.5+1.5j) 15707963/5000000 2 2 2.0 (2+0j) 4 0 4 1 4 0 3.5 0.5 3.0 1.33333333333 2.82842712475 1 7/2 1/2 3 4/3 2.82842712475 1 (3.5+1.5j) (0.5-1.5j) (3+3j) (0.666666666667-0.666666666667j) (1.43248815986+2.43884761145j) 1 1.5 1 1.5 (1.5+0j) 3.5 -0.5 3.0 0.75 2.25 -1 3.0 0.0 2.25 1.0 1.83711730709 0 3.0 0.0 2.25 1.0 1.83711730709 1 (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1 3/2 1 1.5 (1.5+0j) 7/2 -1/2 3 3/4 9/4 -1 3.0 0.0 2.25 1.0 1.83711730709 -1 3 0 9/4 1 1.83711730709 0 (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1 (1.5+1.5j) (1.5+1.5j) (3.5+1.5j) (-0.5+1.5j) (3+3j) (0.75+0.75j) 4.5j -1 (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1 (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1 (3+3j) 0j 4.5j (1+0j) (-0.638110484918+0.705394566962j) 0 ''' print rat(-1L, 1) print rat(1, -1) a = rat(1, 10) print int(a), long(a), float(a), complex(a) b = rat(2, 5) l = [a+b, a-b, a*b, a/b] print l l.sort() print l print rat(0, 1) print a+1 print a+1L print a+1.0 try: print rat(1, 0) raise SystemError, 'should have been ZeroDivisionError' except ZeroDivisionError: print 'OK' print rat(2), rat(1.5), rat(3, 2), rat(1.5+1.5j), rat(31415926,10000000) list = [2, 1.5, rat(3,2), 1.5+1.5j] for i in list: print i, if type(i) is not ComplexType: print int(i), float(i), print complex(i) print for j in list: print i + j, i - j, i * j, i / j, i ** j, cmp(i, j)
71d3aa186579a353a324f0dac9b41910b16f0d16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/71d3aa186579a353a324f0dac9b41910b16f0d16/Rat.py
3/2 1 1.5 (1.5+0j) 7/2 -1/2 3 3/4 9/4 -1
(3/2) 1 1.5 (1.5+0j) (7/2) (-1/2) 3 (3/4) (9/4) -1
def test(): '''\ Test function for rat module. The expected output is (module some differences in floating precission): -1 -1 0 0L 0.1 (0.1+0j) [Rat(1,2), Rat(-3,10), Rat(1,25), Rat(1,4)] [Rat(-3,10), Rat(1,25), Rat(1,4), Rat(1,2)] 0 11/10 11/10 1.1 OK 2 1.5 3/2 (1.5+1.5j) 15707963/5000000 2 2 2.0 (2+0j) 4 0 4 1 4 0 3.5 0.5 3.0 1.33333333333 2.82842712475 1 7/2 1/2 3 4/3 2.82842712475 1 (3.5+1.5j) (0.5-1.5j) (3+3j) (0.666666666667-0.666666666667j) (1.43248815986+2.43884761145j) 1 1.5 1 1.5 (1.5+0j) 3.5 -0.5 3.0 0.75 2.25 -1 3.0 0.0 2.25 1.0 1.83711730709 0 3.0 0.0 2.25 1.0 1.83711730709 1 (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1 3/2 1 1.5 (1.5+0j) 7/2 -1/2 3 3/4 9/4 -1 3.0 0.0 2.25 1.0 1.83711730709 -1 3 0 9/4 1 1.83711730709 0 (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1 (1.5+1.5j) (1.5+1.5j) (3.5+1.5j) (-0.5+1.5j) (3+3j) (0.75+0.75j) 4.5j -1 (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1 (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1 (3+3j) 0j 4.5j (1+0j) (-0.638110484918+0.705394566962j) 0 ''' print rat(-1L, 1) print rat(1, -1) a = rat(1, 10) print int(a), long(a), float(a), complex(a) b = rat(2, 5) l = [a+b, a-b, a*b, a/b] print l l.sort() print l print rat(0, 1) print a+1 print a+1L print a+1.0 try: print rat(1, 0) raise SystemError, 'should have been ZeroDivisionError' except ZeroDivisionError: print 'OK' print rat(2), rat(1.5), rat(3, 2), rat(1.5+1.5j), rat(31415926,10000000) list = [2, 1.5, rat(3,2), 1.5+1.5j] for i in list: print i, if type(i) is not ComplexType: print int(i), float(i), print complex(i) print for j in list: print i + j, i - j, i * j, i / j, i ** j, cmp(i, j)
71d3aa186579a353a324f0dac9b41910b16f0d16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/71d3aa186579a353a324f0dac9b41910b16f0d16/Rat.py
3 0 9/4 1 1.83711730709 0
3 0 (9/4) 1 1.83711730709 0
def test(): '''\ Test function for rat module. The expected output is (module some differences in floating precission): -1 -1 0 0L 0.1 (0.1+0j) [Rat(1,2), Rat(-3,10), Rat(1,25), Rat(1,4)] [Rat(-3,10), Rat(1,25), Rat(1,4), Rat(1,2)] 0 11/10 11/10 1.1 OK 2 1.5 3/2 (1.5+1.5j) 15707963/5000000 2 2 2.0 (2+0j) 4 0 4 1 4 0 3.5 0.5 3.0 1.33333333333 2.82842712475 1 7/2 1/2 3 4/3 2.82842712475 1 (3.5+1.5j) (0.5-1.5j) (3+3j) (0.666666666667-0.666666666667j) (1.43248815986+2.43884761145j) 1 1.5 1 1.5 (1.5+0j) 3.5 -0.5 3.0 0.75 2.25 -1 3.0 0.0 2.25 1.0 1.83711730709 0 3.0 0.0 2.25 1.0 1.83711730709 1 (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1 3/2 1 1.5 (1.5+0j) 7/2 -1/2 3 3/4 9/4 -1 3.0 0.0 2.25 1.0 1.83711730709 -1 3 0 9/4 1 1.83711730709 0 (3+1.5j) -1.5j (2.25+2.25j) (0.5-0.5j) (1.50768393746+1.04970907623j) -1 (1.5+1.5j) (1.5+1.5j) (3.5+1.5j) (-0.5+1.5j) (3+3j) (0.75+0.75j) 4.5j -1 (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1 (3+1.5j) 1.5j (2.25+2.25j) (1+1j) (1.18235814075+2.85446505899j) 1 (3+3j) 0j 4.5j (1+0j) (-0.638110484918+0.705394566962j) 0 ''' print rat(-1L, 1) print rat(1, -1) a = rat(1, 10) print int(a), long(a), float(a), complex(a) b = rat(2, 5) l = [a+b, a-b, a*b, a/b] print l l.sort() print l print rat(0, 1) print a+1 print a+1L print a+1.0 try: print rat(1, 0) raise SystemError, 'should have been ZeroDivisionError' except ZeroDivisionError: print 'OK' print rat(2), rat(1.5), rat(3, 2), rat(1.5+1.5j), rat(31415926,10000000) list = [2, 1.5, rat(3,2), 1.5+1.5j] for i in list: print i, if type(i) is not ComplexType: print int(i), float(i), print complex(i) print for j in list: print i + j, i - j, i * j, i / j, i ** j, cmp(i, j)
71d3aa186579a353a324f0dac9b41910b16f0d16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/71d3aa186579a353a324f0dac9b41910b16f0d16/Rat.py
"[-s regexp] [directory ...]"
"[-x regexp] [directory ...]"
def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:') except getopt.error, msg: print msg print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-q: quiet operation" print "-d destdir: purported directory name for error messages" print " if no directory arguments, -l sys.path is assumed" print "-x regexp: skip files matching the regular expression regexp" print " the regexp is search for in the full path of the file" sys.exit(2) maxlevels = 10 ddir = None force = 0 quiet = 0 rx = None for o, a in opts: if o == '-l': maxlevels = 0 if o == '-d': ddir = a if o == '-f': force = 1 if o == '-q': quiet = 1 if o == '-x': import re rx = re.compile(a) if ddir: if len(args) != 1: print "-d destdir require exactly one directory argument" sys.exit(2) success = 1 try: if args: for dir in args: if not compile_dir(dir, maxlevels, ddir, force, rx, quiet): success = 0 else: success = compile_path() except KeyboardInterrupt: print "\n[interrupt]" success = 0 return success
f92008b35ef065c70e8cb54a344b5f9cc2e07c41 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f92008b35ef065c70e8cb54a344b5f9cc2e07c41/compileall.py
int i;
int i, result;
def visitModule(self, mod): self.emit("""
ee33a34d4f6d7e33d3b6da7df3701570d9fff33a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ee33a34d4f6d7e33d3b6da7df3701570d9fff33a/asdl_c.py
for(i=0; i < num_fields; i++) {
for(i = 0; i < num_fields; i++) {
def visitModule(self, mod): self.emit("""
ee33a34d4f6d7e33d3b6da7df3701570d9fff33a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ee33a34d4f6d7e33d3b6da7df3701570d9fff33a/asdl_c.py
return PyObject_SetAttrString((PyObject*)type, "_attributes", l) >=0;
result = PyObject_SetAttrString((PyObject*)type, "_attributes", l) >= 0; Py_DECREF(l); return result;
def visitModule(self, mod): self.emit("""
ee33a34d4f6d7e33d3b6da7df3701570d9fff33a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ee33a34d4f6d7e33d3b6da7df3701570d9fff33a/asdl_c.py