bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def __init__(self, logfn): # fileno -> filename self._filemap = {} # (fileno, lineno) -> filename, funcname self._funcmap = {} | def __init__(self, logfn): # fileno -> filename self._filemap = {} # (fileno, lineno) -> filename, funcname self._funcmap = {} | 457,200 |
def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False): """Recursively copy a directory tree. 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 t... | def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False): """Recursively copy a directory tree. 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 t... | 457,201 |
def upload_file(self, command, pyversion, filename): # Makes sure the repository URL is compliant schema, netloc, url, params, query, fragments = \ urlparse.urlparse(self.repository) if params or query or fragments: raise AssertionError("Incompatible url %s" % self.repository) | def upload_file(self, command, pyversion, filename): # Makes sure the repository URL is compliant schema, netloc, url, params, query, fragments = \ urlparse.urlparse(self.repository) if params or query or fragments: raise AssertionError("Incompatible url %s" % self.repository) | 457,202 |
def docclass(self, object, name=None, mod=None): """Produce text documentation for a given class object.""" realname = object.__name__ name = name or realname bases = object.__bases__ | def docclass(self, object, name=None, mod=None, *ignored): """Produce text documentation for a given class object.""" realname = object.__name__ name = name or realname bases = object.__bases__ | 457,203 |
def check(self, o, v): with test_support._check_py3k_warnings(): self.assertEqual(operator.isCallable(o), v) self.assertEqual(callable(o), v) | def check(self, o, v): with test_support._check_py3k_warnings(): self.assertEqual(callable(o), v) | 457,204 |
def test_contains(self): self.assertRaises(TypeError, operator.contains) self.assertRaises(TypeError, operator.contains, None, None) self.assertTrue(operator.contains(range(4), 2)) self.assertFalse(operator.contains(range(4), 5)) with test_support._check_py3k_warnings(): self.assertTrue(operator.sequenceIncludes(range(... | def test_contains(self): self.assertRaises(TypeError, operator.contains) self.assertRaises(TypeError, operator.contains, None, None) self.assertTrue(operator.contains(range(4), 2)) self.assertFalse(operator.contains(range(4), 5)) with test_support._check_py3k_warnings(): self.assertTrue(operator.sequenceIncludes(range(... | 457,205 |
def test_shell_string_with_spaces(self): # call() function with string argument with spaces on Windows self.with_spaces('"%s" "%s"' % (self.fname, "ab cd"), shell=1) | def test_shell_string_with_spaces(self): # call() function with string argument with spaces on Windows self.with_spaces('"%s" "%s"' % (self.fname, "ab cd"), shell=1) | 457,206 |
def test_shell_sequence_with_spaces(self): # call() function with sequence argument with spaces on Windows self.with_spaces([self.fname, "ab cd"], shell=1) | def test_shell_sequence_with_spaces(self): # call() function with sequence argument with spaces on Windows self.with_spaces([self.fname, "ab cd"], shell=1) | 457,207 |
def test_trace(self): self.assertEqual(len(git.tr), 3) self.assertEqual(git.tr[0][1:], (modfile, 43, 'argue', [' spam(a, b, c)\n'], 0)) self.assertEqual(git.tr[1][1:], (modfile, 9, 'spam', [' eggs(b + d, c + f)\n'], 0)) self.assertEqual(git.tr[2][1:], (modfile, 18, 'eggs', [' q = y / 0\n'], 0)) | def test_trace(self): self.assertEqual(len(git.tr), 3) self.assertEqual(git.tr[0][1:], (modfile, 43, 'argue', [' spam(a, b, c)\n'], 0)) self.assertEqual(git.tr[1][1:], (modfile, 9, 'spam', [' eggs(b + d, c + f)\n'], 0)) self.assertEqual(git.tr[2][1:], (modfile, 18, 'eggs', [' q = y / 0\n'], 0)) | 457,208 |
def abspath(path): """Return an absolute path.""" if not isabs(path): path = join(os.getcwd(), path) return normpath(path) | def abspath(path): """Return an absolute path.""" if not isabs(path): if isinstance(path, bytes): cwd = os.getcwdb() else: cwd = os.getcwd() path = join(cwd, path) return normpath(path) | 457,209 |
def test_constructors(self): super().test_len() # calling built-in types without argument must return empty self.assertEqual(tuple(), ()) t0_3 = (0, 1, 2, 3) t0_3_bis = tuple(t0_3) self.assertTrue(t0_3 is t0_3_bis) self.assertEqual(tuple([]), ()) self.assertEqual(tuple([0, 1, 2, 3]), (0, 1, 2, 3)) self.assertEqual(tupl... | def test_constructors(self): super().test_constructors() # calling built-in types without argument must return empty self.assertEqual(tuple(), ()) t0_3 = (0, 1, 2, 3) t0_3_bis = tuple(t0_3) self.assertTrue(t0_3 is t0_3_bis) self.assertEqual(tuple([]), ()) self.assertEqual(tuple([0, 1, 2, 3]), (0, 1, 2, 3)) self.assertE... | 457,210 |
def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session): """Execute program (MS Windows version)""" | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session): """Execute program (MS Windows version)""" | 457,211 |
def test(self): huge = 1L << 40000 mhuge = -huge self.assertEqual(huge / huge, 1.0) self.assertEqual(mhuge / mhuge, 1.0) self.assertEqual(huge / mhuge, -1.0) self.assertEqual(mhuge / huge, -1.0) self.assertEqual(1 / huge, 0.0) self.assertEqual(1L / huge, 0.0) self.assertEqual(1 / mhuge, 0.0) self.assertEqual(1L / mhuge... | def test(self): huge = 1L << 40000 mhuge = -huge self.assertEqual(huge / huge, 1.0) self.assertEqual(mhuge / mhuge, 1.0) self.assertEqual(huge / mhuge, -1.0) self.assertEqual(mhuge / huge, -1.0) self.assertEqual(1 / huge, 0.0) self.assertEqual(1L / huge, 0.0) self.assertEqual(1 / mhuge, 0.0) self.assertEqual(1L / mhuge... | 457,212 |
def main(): usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..." parser = OptionParser(usage=usage) parser.allow_interspersed_args = False parser.add_option('-o', '--outfile', dest="outfile", help="Save stats to <outfile>", default=None) parser.add_option('-s', '--sort', dest="sort", help="Sort ord... | def main(): usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..." parser = OptionParser(usage=usage) parser.allow_interspersed_args = False parser.add_option('-o', '--outfile', dest="outfile", help="Save stats to <outfile>", default=None) parser.add_option('-s', '--sort', dest="sort", help="Sort ord... | 457,213 |
def main(): usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..." parser = OptionParser(usage=usage) parser.allow_interspersed_args = False parser.add_option('-o', '--outfile', dest="outfile", help="Save stats to <outfile>", default=None) parser.add_option('-s', '--sort', dest="sort", help="Sort ord... | def main(): usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..." parser = OptionParser(usage=usage) parser.allow_interspersed_args = False parser.add_option('-o', '--outfile', dest="outfile", help="Save stats to <outfile>", default=None) parser.add_option('-s', '--sort', dest="sort", help="Sort ord... | 457,214 |
def testSimpleSSLwrap(self): # A crude test for the legacy API try: ssl.sslwrap_simple(socket.socket(socket.AF_INET)) except IOError, e: if e.errno == 32: # broken pipe when ssl_sock.do_handshake(), this test doesn't care about that pass else: raise try: ssl.sslwrap_simple(socket.socket(socket.AF_INET)._sock) except IO... | def test_sslwrap_simple(self): # A crude test for the legacy API try: ssl.sslwrap_simple(socket.socket(socket.AF_INET)) except IOError, e: if e.errno == 32: # broken pipe when ssl_sock.do_handshake(), this test doesn't care about that pass else: raise try: ssl.sslwrap_simple(socket.socket(socket.AF_INET)._sock) except ... | 457,215 |
def testSSLconnect(self): if not test_support.is_resource_enabled('network'): return s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE) s.connect(("svn.python.org", 443)) c = s.getpeercert() if c: self.fail("Peer cert %s shouldn't be here!") s.close() | def test_connect(self): if not test_support.is_resource_enabled('network'): return s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE) s.connect(("svn.python.org", 443)) c = s.getpeercert() if c: self.fail("Peer cert %s shouldn't be here!") s.close() | 457,216 |
def testCrucialConstants(self): ssl.PROTOCOL_SSLv2 ssl.PROTOCOL_SSLv23 ssl.PROTOCOL_SSLv3 ssl.PROTOCOL_TLSv1 ssl.CERT_NONE ssl.CERT_OPTIONAL ssl.CERT_REQUIRED | def test_constants(self): ssl.PROTOCOL_SSLv2 ssl.PROTOCOL_SSLv23 ssl.PROTOCOL_SSLv3 ssl.PROTOCOL_TLSv1 ssl.CERT_NONE ssl.CERT_OPTIONAL ssl.CERT_REQUIRED | 457,217 |
def testRAND(self): v = ssl.RAND_status() if test_support.verbose: sys.stdout.write("\n RAND_status is %d (%s)\n" % (v, (v and "sufficient randomness") or "insufficient randomness")) try: ssl.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" ssl.RAND_add("this is a random string", 75.0) | def test_random(self): v = ssl.RAND_status() if test_support.verbose: sys.stdout.write("\n RAND_status is %d (%s)\n" % (v, (v and "sufficient randomness") or "insufficient randomness")) try: ssl.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" ssl.RAND_add("this is a random string", 75.0) | 457,218 |
def testParseCert(self): # note that this uses an 'unofficial' function in _ssl.c, # provided solely for this test, to exercise the certificate # parsing code p = ssl._ssl._test_decode_cert(CERTFILE, False) if test_support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") | def test_parse_cert(self): # note that this uses an 'unofficial' function in _ssl.c, # provided solely for this test, to exercise the certificate # parsing code p = ssl._ssl._test_decode_cert(CERTFILE, False) if test_support.verbose: sys.stdout.write("\n" + pprint.pformat(p) + "\n") | 457,219 |
def testDERtoPEM(self): | def testDERtoPEM(self): | 457,220 |
def testConnect(self): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE) s.connect(("svn.python.org", 443)) c = s.getpeercert() if c: self.fail("Peer cert %s shouldn't be here!") s.close() | def test_connect(self): s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE) s.connect(("svn.python.org", 443)) c = s.getpeercert() if c: self.fail("Peer cert %s shouldn't be here!") s.close() | 457,221 |
def testNonBlockingHandshake(self): s = socket.socket(socket.AF_INET) s.connect(("svn.python.org", 443)) s.setblocking(False) s = ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE, do_handshake_on_connect=False) count = 0 while True: try: count += 1 s.do_handshake() break except ssl.SSLError, err: if err.args[0] == ssl.SSL_ER... | def test_non_blocking_handshake(self): s = socket.socket(socket.AF_INET) s.connect(("svn.python.org", 443)) s.setblocking(False) s = ssl.wrap_socket(s, cert_reqs=ssl.CERT_NONE, do_handshake_on_connect=False) count = 0 while True: try: count += 1 s.do_handshake() break except ssl.SSLError, err: if err.args[0] == ssl.SSL... | 457,222 |
def testFetchServerCert(self): | def testFetchServerCert(self): | 457,223 |
def test_algorithms(self): # Issue #8484: all algorithms should be available when verifying a # certificate. # SHA256 was added in OpenSSL 0.9.8 if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15): self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION) # NOTE: https://sha256.tbs-internet.com is another possible t... | deftest_algorithms(self):#Issue#8484:allalgorithmsshouldbeavailablewhenverifyinga#certificate.#SHA256wasaddedinOpenSSL0.9.8ifssl.OPENSSL_VERSION_INFO<(0,9,8,0,15):self.skipTest("SHA256notavailableon%r"%ssl.OPENSSL_VERSION)#NOTE:https://sha256.tbs-internet.comisanotherpossibletesthostremote=("sha2.hboeck.de",443)sha256_... | 457,224 |
def wrap_conn (self): try: self.sslconn = ssl.wrap_socket(self.sock, server_side=True, certfile=self.server.certificate, ssl_version=self.server.protocol, ca_certs=self.server.cacerts, cert_reqs=self.server.certreqs, ciphers=self.server.ciphers) except ssl.SSLError: # XXX Various errors can have happened here, for exam... | def wrap_conn(self): try: self.sslconn = ssl.wrap_socket(self.sock, server_side=True, certfile=self.server.certificate, ssl_version=self.server.protocol, ca_certs=self.server.cacerts, cert_reqs=self.server.certreqs, ciphers=self.server.ciphers) except ssl.SSLError: # XXX Various errors can have happened here, for examp... | 457,225 |
def run (self): self.running = True if not self.server.starttls_server: if isinstance(self.sock, ssl.SSLSocket): self.sslconn = self.sock elif not self.wrap_conn(): return self.show_conn_details() while self.running: try: msg = self.read() if not msg: # eof, so quit this handler self.running = False self.close() elif m... | def run(self): self.running = True if not self.server.starttls_server: if isinstance(self.sock, ssl.SSLSocket): self.sslconn = self.sock elif not self.wrap_conn(): return self.show_conn_details() while self.running: try: msg = self.read() if not msg: # eof, so quit this handler self.running = False self.close() elif ms... | 457,226 |
def start (self, flag=None): self.flag = flag threading.Thread.start(self) | def start(self, flag=None): self.flag = flag threading.Thread.start(self) | 457,227 |
def run (self): self.sock.settimeout(0.05) self.sock.listen(5) self.active = True if self.flag: # signal an event self.flag.set() while self.active: try: newconn, connaddr = self.sock.accept() if test_support.verbose and self.chatty: sys.stdout.write(' server: new connection from ' + str(connaddr) + '\n') handler = se... | def run(self): self.sock.settimeout(0.05) self.sock.listen(5) self.active = True if self.flag: # signal an event self.flag.set() while self.active: try: newconn, connaddr = self.sock.accept() if test_support.verbose and self.chatty: sys.stdout.write(' server: new connection from ' + str(connaddr) + '\n') handler = sel... | 457,228 |
def stop (self): self.active = False | def stop(self): self.active = False | 457,229 |
def stop (self): self.active = False | def stop (self): self.active = False | 457,230 |
def start (self, flag=None): self.flag = flag threading.Thread.start(self) | def start(self, flag=None): self.flag = flag threading.Thread.start(self) | 457,231 |
def run (self): self.active = True if self.flag: self.flag.set() while self.active: asyncore.loop(0.05) | def run(self): self.active = True if self.flag: self.flag.set() while self.active: asyncore.loop(0.05) | 457,232 |
def stop (self): self.active = False self.server.close() | def stop(self): self.active = False self.server.close() | 457,233 |
def __init__(self, server_address, RequestHandlerClass, certfile): | def__init__(self,server_address,RequestHandlerClass,certfile): | 457,234 |
def __init__(self, server_address, RequestHandlerClass, certfile): | def __init__(self, server_address, RequestHandlerClass, certfile): | 457,235 |
def get_request (self): # override this to wrap socket with SSL sock, addr = self.socket.accept() sslconn = ssl.wrap_socket(sock, server_side=True, certfile=self.certfile) return sslconn, addr | def get_request(self): # override this to wrap socket with SSL sock, addr = self.socket.accept() sslconn = ssl.wrap_socket(sock, server_side=True, certfile=self.certfile) return sslconn, addr | 457,236 |
def get_request (self): # override this to wrap socket with SSL sock, addr = self.socket.accept() sslconn = ssl.wrap_socket(sock, server_side=True, certfile=self.certfile) return sslconn, addr | defget_request(self):#overridethistowrapsocketwithSSLsock,addr=self.socket.accept()sslconn=ssl.wrap_socket(sock,server_side=True,certfile=self.certfile)returnsslconn,addr | 457,237 |
def __init__(self, certfile): self.flag = None self.active = False self.RootedHTTPRequestHandler.root = os.path.split(CERTFILE)[0] self.server = self.HTTPSServer( (HOST, 0), self.RootedHTTPRequestHandler, certfile) self.port = self.server.server_port threading.Thread.__init__(self) self.daemon = True | def __init__(self, certfile): self.flag = None self.RootedHTTPRequestHandler.root = os.path.split(CERTFILE)[0] self.server = self.HTTPSServer( (HOST, 0), self.RootedHTTPRequestHandler, certfile) self.port = self.server.server_port threading.Thread.__init__(self) self.daemon = True | 457,238 |
def start (self, flag=None): self.flag = flag threading.Thread.start(self) | def start(self, flag=None): self.flag = flag threading.Thread.start(self) | 457,239 |
def run (self): self.active = True if self.flag: self.flag.set() self.server.serve_forever(0.05) self.active = False | def run(self): if self.flag: self.flag.set() self.server.serve_forever(0.05) self.active = False | 457,240 |
def run (self): self.active = True if self.flag: self.flag.set() self.server.serve_forever(0.05) self.active = False | def run (self): self.active = True if self.flag: self.flag.set() self.server.serve_forever(0.05) self.active = False | 457,241 |
def badCertTest (certfile): server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_REQUIRED, cacerts=CERTFILE, chatty=False) flag = threading.Event() server.start(flag) # wait for it to start flag.wait() # try to connect try: try: s = ssl.wrap_socket(socket.socket(), certfile=certfile, ssl_version=ssl.PROTOCOL_TLSv1) ... | def bad_cert_test(certfile): """ Launch a server with CERT_REQUIRED, and check that trying to connect to it with the given client certificate fails. """ server = ThreadedEchoServer(CERTFILE, certreqs=ssl.CERT_REQUIRED, cacerts=CERTFILE, chatty=False) flag = threading.Event() server.start(flag) # wait for it to start fl... | 457,242 |
def serverParamsTest (certfile, protocol, certreqs, cacertsfile, client_certfile, client_protocol=None, indata="FOO\n", ciphers=None, chatty=True, connectionchatty=False, wrap_accepting_socket=False): | def serverParamsTest (certfile, protocol, certreqs, cacertsfile, client_certfile, client_protocol=None, indata="FOO\n", ciphers=None, chatty=True, connectionchatty=False, wrap_accepting_socket=False): | 457,243 |
def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | 457,244 |
def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | 457,245 |
def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | 457,246 |
def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | 457,247 |
def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | 457,248 |
def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | 457,249 |
def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | def tryProtocolCombo (server_protocol, client_protocol, expectedToWork, certsreqs=None): | 457,250 |
def testRudeShutdown(self): | def testRudeShutdown(self): | 457,251 |
def testEcho (self): | def testEcho (self): | 457,252 |
def testEcho (self): | def testEcho (self): | 457,253 |
def testNULLcert(self): badCertTest(os.path.join(os.path.dirname(__file__) or os.curdir, "nullcert.pem")) | def testNULLcert(self): badCertTest(os.path.join(os.path.dirname(__file__) or os.curdir, "nullcert.pem")) | 457,254 |
def testProtocolSSL2(self): if test_support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True) tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL) tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED) tryProtocolCombo(... | def testProtocolSSL2(self): if test_support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True) tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL) tryProtocolCombo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED) tryProtocolCombo(... | 457,255 |
def testProtocolSSL23(self): if test_support.verbose: sys.stdout.write("\n") try: tryProtocolCombo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) except (ssl.SSLError, socket.error), x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) if test_support.verbose: sys.stdout.write( " SSL2 client to SSL2... | def testProtocolSSL23(self): if test_support.verbose: sys.stdout.write("\n") try: try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) except (ssl.SSLError, socket.error), x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) if test_support.verbose: sys.stdout.write( " SSL2 client to SS... | 457,256 |
def testProtocolSSL23(self): if test_support.verbose: sys.stdout.write("\n") try: tryProtocolCombo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) except (ssl.SSLError, socket.error), x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) if test_support.verbose: sys.stdout.write( " SSL2 client to SSL2... | def testProtocolSSL23(self): if test_support.verbose: sys.stdout.write("\n") try: tryProtocolCombo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) except (ssl.SSLError, socket.error), x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) if test_support.verbose: sys.stdout.write( " SSL2 client to SSL2... | 457,257 |
def testProtocolSSL3(self): if test_support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True) tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL) tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_REQUIRED) tryProtocolCombo(... | def testProtocolSSL3(self): if test_support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True) tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL) tryProtocolCombo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_REQUIRED) tryProtocolCombo(... | 457,258 |
def testProtocolTLS1(self): if test_support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True) tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL) tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED) tryProtocolCombo(... | def testProtocolTLS1(self): if test_support.verbose: sys.stdout.write("\n") tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True) tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL) tryProtocolCombo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED) tryProtocolCombo(... | 457,259 |
def testSocketServer(self): | def testSocketServer(self): | 457,260 |
def testSocketServer(self): | def testSocketServer(self): | 457,261 |
def testWrappedAccept (self): | def testWrappedAccept (self): | 457,262 |
def testWrappedAccept (self): | def testWrappedAccept (self): | 457,263 |
def testAsyncoreServer (self): | def testAsyncoreServer (self): | 457,264 |
def test_main(verbose=False): if skip_expected: raise unittest.SkipTest("No SSL support") global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") SVN_PYTHON_ORG_ROOT_CERT = os.path.join( os.path.dirname(__file__) or os.curdir, "https_svn_python_org_root.... | def test_main(verbose=False): if skip_expected: raise unittest.SkipTest("No SSL support") global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert.pem") SVN_PYTHON_ORG_ROOT_CERT = os.path.join( os.path.dirname(__file__) or os.curdir, "https_svn_python_org_root.... | 457,265 |
def get_python_inc(plat_specific=0, prefix=None): """Return the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header files (namely pycon... | def get_python_inc(plat_specific=0, prefix=None): """Return the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header files (namely pycon... | 457,266 |
def get_makefile_filename(): """Return full pathname of installed Makefile from the Python build.""" if python_build: return os.path.join(os.path.dirname(sys.executable), "Makefile") lib_dir = get_python_lib(plat_specific=1, standard_lib=1) return os.path.join(lib_dir, "config", "Makefile") | def get_makefile_filename(): """Return full pathname of installed Makefile from the Python build.""" if python_build: return os.path.join(os.path.dirname(os.path.realpath(sys.executable)), "Makefile") lib_dir = get_python_lib(plat_specific=1, standard_lib=1) return os.path.join(lib_dir, "config", "Makefile") | 457,267 |
def _init_nt(): """Initialize the module as appropriate for NT""" g = {} # set basic install directories g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) # XXX hmmm.. a normal install puts include files here g['INCLUDEPY'] = get_python_inc... | def _init_nt(): """Initialize the module as appropriate for NT""" g = {} # set basic install directories g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) # XXX hmmm.. a normal install puts include files here g['INCLUDEPY'] = get_python_inc... | 457,268 |
def test_send_signal(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | def test_send_signal(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | 457,269 |
def test_kill(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | def test_kill(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | 457,270 |
def test_terminate(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | def test_terminate(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | 457,271 |
def test_ignored(self): ignore = trace.Ignore(['x', 'y.z'], ['/foo/bar']) self.assertTrue(ignore.names('x.py', 'x')) self.assertFalse(ignore.names('xy.py', 'xy')) self.assertFalse(ignore.names('y.py', 'y')) self.assertTrue(ignore.names('/foo/bar/baz.py', 'baz')) self.assertFalse(ignore.names('bar/z.py', 'z')) # Matched... | def test_ignored(self): jn = os.path.join ignore = trace.Ignore(['x', 'y.z'], [jn('foo', 'bar')]) self.assertTrue(ignore.names('x.py', 'x')) self.assertFalse(ignore.names('xy.py', 'xy')) self.assertFalse(ignore.names('y.py', 'y')) self.assertTrue(ignore.names('/foo/bar/baz.py', 'baz')) self.assertFalse(ignore.names('ba... | 457,272 |
def test_ignored(self): ignore = trace.Ignore(['x', 'y.z'], ['/foo/bar']) self.assertTrue(ignore.names('x.py', 'x')) self.assertFalse(ignore.names('xy.py', 'xy')) self.assertFalse(ignore.names('y.py', 'y')) self.assertTrue(ignore.names('/foo/bar/baz.py', 'baz')) self.assertFalse(ignore.names('bar/z.py', 'z')) # Matched... | def test_ignored(self): ignore = trace.Ignore(['x', 'y.z'], ['/foo/bar']) self.assertTrue(ignore.names('x.py', 'x')) self.assertFalse(ignore.names('xy.py', 'xy')) self.assertFalse(ignore.names('y.py', 'y')) self.assertTrue(ignore.names(jn('foo', 'bar', 'baz.py'), 'baz')) self.assertFalse(ignore.names(jn('bar', 'z.py'),... | 457,273 |
def test_ignored(self): ignore = trace.Ignore(['x', 'y.z'], ['/foo/bar']) self.assertTrue(ignore.names('x.py', 'x')) self.assertFalse(ignore.names('xy.py', 'xy')) self.assertFalse(ignore.names('y.py', 'y')) self.assertTrue(ignore.names('/foo/bar/baz.py', 'baz')) self.assertFalse(ignore.names('bar/z.py', 'z')) # Matched... | def test_ignored(self): ignore = trace.Ignore(['x', 'y.z'], ['/foo/bar']) self.assertTrue(ignore.names('x.py', 'x')) self.assertFalse(ignore.names('xy.py', 'xy')) self.assertFalse(ignore.names('y.py', 'y')) self.assertTrue(ignore.names('/foo/bar/baz.py', 'baz')) self.assertFalse(ignore.names('bar/z.py', 'z')) # Matched... | 457,274 |
def test_garbage_collection(self): # FileIO objects are collected, and collecting them flushes # all data to disk. f = self.FileIO(support.TESTFN, "wb") f.write(b"abcxxx") f.f = f wr = weakref.ref(f) del f support.gc_collect() self.assertTrue(wr() is None, wr) with self.open(support.TESTFN, "rb") as f: self.assertEqual... | def test_garbage_collection(self): # FileIO objects are collected, and collecting them flushes # all data to disk. with support.check_warnings(('', ResourceWarning)): f = self.FileIO(support.TESTFN, "wb") f.write(b"abcxxx") f.f = f wr = weakref.ref(f) del f support.gc_collect() self.assertTrue(wr() is None, wr) with se... | 457,275 |
def test_seeking(self): chunk_size = _default_chunk_size() prefix_size = chunk_size - 2 u_prefix = "a" * prefix_size prefix = bytes(u_prefix.encode("utf-8")) self.assertEquals(len(u_prefix), len(prefix)) u_suffix = "\u8888\n" suffix = bytes(u_suffix.encode("utf-8")) line = prefix + suffix f = self.open(support.TESTFN, ... | def test_seeking(self): chunk_size = _default_chunk_size() prefix_size = chunk_size - 2 u_prefix = "a" * prefix_size prefix = bytes(u_prefix.encode("utf-8")) self.assertEquals(len(u_prefix), len(prefix)) u_suffix = "\u8888\n" suffix = bytes(u_suffix.encode("utf-8")) line = prefix + suffix f = self.open(support.TESTFN, ... | 457,276 |
def test_seeking_too(self): # Regression test for a specific bug data = b'\xe0\xbf\xbf\n' f = self.open(support.TESTFN, "wb") f.write(data) f.close() f = self.open(support.TESTFN, "r", encoding="utf-8") f._CHUNK_SIZE # Just test that it exists f._CHUNK_SIZE = 2 f.readline() f.tell() | def test_seeking_too(self): # Regression test for a specific bug data = b'\xe0\xbf\xbf\n' f = self.open(support.TESTFN, "wb") f.write(data) f.close() f = self.open(support.TESTFN, "r", encoding="utf-8") f._CHUNK_SIZE # Just test that it exists f._CHUNK_SIZE = 2 f.readline() f.tell() | 457,277 |
def test_get_platform(self): # windows XP, 32bits os.name = 'nt' sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) ' '[MSC v.1310 32 bit (Intel)]') sys.platform = 'win32' self.assertEquals(get_platform(), 'win32') | def test_get_platform(self): # windows XP, 32bits os.name = 'nt' sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) ' '[MSC v.1310 32 bit (Intel)]') sys.platform = 'win32' self.assertEquals(get_platform(), 'win32') | 457,278 |
def relpath(path, start=curdir): """Return a relative version of a path""" sep = _get_sep(path) if start is curdir: start = _get_dot(path) if not path: raise ValueError("no path specified") start_abs = abspath(normpath(start)) path_abs = abspath(normpath(path)) start_drive, start_rest = splitdrive(start_abs) path_dr... | def relpath(path, start=curdir): """Return a relative version of a path""" sep = _get_sep(path) if start is curdir: start = _get_dot(path) if not path: raise ValueError("no path specified") start_abs = abspath(normpath(start)) path_abs = abspath(normpath(path)) start_drive, start_rest = splitdrive(start_abs) path_dr... | 457,279 |
def relpath(path, start=curdir): """Return a relative version of a path""" sep = _get_sep(path) if start is curdir: start = _get_dot(path) if not path: raise ValueError("no path specified") start_abs = abspath(normpath(start)) path_abs = abspath(normpath(path)) start_drive, start_rest = splitdrive(start_abs) path_dr... | def relpath(path, start=curdir): """Return a relative version of a path""" sep = _get_sep(path) if start is curdir: start = _get_dot(path) if not path: raise ValueError("no path specified") start_abs = abspath(normpath(start)) path_abs = abspath(normpath(path)) start_drive, start_rest = splitdrive(start_abs) path_dr... | 457,280 |
def _do_test_commandline(self, cmdline, expected): cmd = '"%s" -c "import sys;print sys.argv" %s' % (python, cmdline) data = os.popen(cmd).read() got = eval(data)[1:] # strip off argv[0] self.assertEqual(got, expected) | def _do_test_commandline(self, cmdline, expected): cmd = '"%s" -c "import sys;print sys.argv" %s' % (python, cmdline) data = os.popen(cmd).read() + '\n' got = eval(data)[1:] # strip off argv[0] self.assertEqual(got, expected) | 457,281 |
def check_float_coerce(self, format, number): # SF bug 1530559. struct.pack raises TypeError where it used to convert. with warnings.catch_warnings(): warnings.filterwarnings( "ignore", category=DeprecationWarning, message=".*integer argument expected, got float", module=__name__) self.assertEqual(struct.pack(format, n... | def check_float_coerce(self, format, number): # SF bug 1530559. struct.pack raises TypeError where it used to convert. with warnings.catch_warnings(record=True) as w: warnings.simplefilter("ignore") warnings.filterwarnings( "ignore", category=DeprecationWarning, message=".*integer argument expected, got float", modu... | 457,282 |
def check_float_coerce(self, format, number): # SF bug 1530559. struct.pack raises TypeError where it used to convert. with warnings.catch_warnings(): warnings.filterwarnings( "ignore", category=DeprecationWarning, message=".*integer argument expected, got float", module=__name__) self.assertEqual(struct.pack(format, n... | def check_float_coerce(self, format, number): # SF bug 1530559. struct.pack raises TypeError where it used to convert. with warnings.catch_warnings(): warnings.filterwarnings( "always", message=".*integer argument expected, got float", category=DeprecationWarning, message=".*integer argument expected, got float", modul... | 457,283 |
def check_float_coerce(self, format, number): # SF bug 1530559. struct.pack raises TypeError where it used to convert. with warnings.catch_warnings(): warnings.filterwarnings( "ignore", category=DeprecationWarning, message=".*integer argument expected, got float", module=__name__) self.assertEqual(struct.pack(format, n... | def check_float_coerce(self, format, number): # SF bug 1530559. struct.pack raises TypeError where it used to convert. with warnings.catch_warnings(): warnings.filterwarnings( "ignore", category=DeprecationWarning, message=".*integer argument expected, got float", module=__name__) self.assertEqual(struct.pack(format, n... | 457,284 |
def __int__(self): return 10585 | def __int__(self): return 10585 | 457,285 |
def __long__(self): return -163L | def __long__(self): return -163L | 457,286 |
def test_pr29(self): # http://www.unicode.org/review/pr-29.html for text in (u"\u0b47\u0300\u0b3e", u"\u1100\u0300\u1161"): self.assertEqual(self.db.normalize('NFC', text), text) | def test_pr29(self): # http://www.unicode.org/review/pr-29.html for text in ("\u0b47\u0300\u0b3e", "\u1100\u0300\u1161"): self.assertEqual(self.db.normalize('NFC', text), text) | 457,287 |
def test_getfilesystemencoding(self): fs_encoding = sys.getfilesystemencoding() if sys.platform == 'darwin': expected = 'utf-8' elif sys.platform == 'win32': expected = 'mbcs' else: expected = None self.check_fsencoding(fs_encoding) | def test_getfilesystemencoding(self): fs_encoding = sys.getfilesystemencoding() if sys.platform == 'darwin': expected = 'utf-8' elif sys.platform == 'win32': expected = 'mbcs' else: expected = None self.check_fsencoding(fs_encoding) | 457,288 |
def test_halfway_cases(self): # test halfway cases for the round-half-to-even rule for i in xrange(1000): for j in xrange(TEST_SIZE): # bit pattern for a random finite positive (or +0.0) float bits = random.randrange(2047*2**52) | def test_halfway_cases(self): # test halfway cases for the round-half-to-even rule for i in xrange(1000): for j in xrange(TEST_SIZE): # bit pattern for a random finite positive (or +0.0) float bits = random.randrange(2047*2**52) | 457,289 |
def test_parsing(self): digits = tuple(map(str, xrange(10))) signs = ('+', '-', '') | def test_parsing(self): digits = '000000123456789' signs = ('+', '-', '') | 457,290 |
def test_particular(self): # inputs that produced crashes or incorrectly rounded results with # previous versions of dtoa.c, for various reasons test_strings = [ # issue 7632 bug 1, originally reported failing case '2183167012312112312312.23538020374420446192e-370', # 5 instances of issue 7632 bug 2 '125798160490083055... | def'10000000000000000000000000000000000000000e-17', test_particular(self):'10000000000000000000000000000000000000000e-17', #'10000000000000000000000000000000000000000e-17', inputs'10000000000000000000000000000000000000000e-17', that'10000000000000000000000000000000000000000e-17', produced'100000000000000000000000000000... | 457,291 |
def __init__(self, port, callback): host = 'localhost' self.address = ('', port) self.url = 'http://%s:%d/' % (host, port) self.callback = callback self.base.__init__(self, self.address, self.handler) | def __init__(self, port, callback): host = 'localhost' self.address = (host, port) self.url = 'http://%s:%d/' % (host, port) self.callback = callback self.base.__init__(self, self.address, self.handler) | 457,292 |
def test_combined_single_invalid_option(self): self.parser.add_option("-t", action="store_true") self.assertParseFail(["-test"], "no such option: -e") | def test_combined_single_invalid_option(self): self.parser.add_option("-t", action="store_true") self.assertParseFail(["-test"], "no such option: -e") | 457,293 |
def test_putheader(self): conn = client.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn.putrequest('GET','/') conn.putheader('Content-length', 42) print(conn._buffer) self.assertTrue(b'Content-length: 42' in conn._buffer) | def test_putheader(self): conn = client.HTTPConnection('example.com') conn.sock = FakeSocket(None) conn.putrequest('GET','/') conn.putheader('Content-length', 42) self.assertTrue(b'Content-length: 42' in conn._buffer) | 457,294 |
def test_bad_bytecode(self): # Malformed code object bytecode should lead to a ValueError. name = 'mod' bc = {name: {'path': os.path.join('path', 'to', 'mod'), 'bc': b'NNN'}} mock = PyPycLoaderMock({name: None}, bc) with util.uncache(name), self.assertRaises(ValueError): mock.load_module(name) | def test_bad_bytecode(self): # Malformed code object bytecode should lead to a ValueError. name = 'mod' bc = {name: {'path': os.path.join('path', 'to', 'mod'), 'bc': b'1234'}} mock = PyPycLoaderMock({name: None}, bc) with util.uncache(name), self.assertRaises(ValueError): mock.load_module(name) | 457,295 |
def testGetaddrinfo(self): try: socket.getaddrinfo('localhost', 80) except socket.gaierror as err: if err.errno == socket.EAI_SERVICE: # see http://bugs.python.org/issue1282647 self.skipTest("buggy libc version") raise # len of every sequence is supposed to be == 5 for info in socket.getaddrinfo(HOST, None): self.asser... | def testGetaddrinfo(self): try: socket.getaddrinfo('localhost', 80) except socket.gaierror as err: if err.errno == socket.EAI_SERVICE: # see http://bugs.python.org/issue1282647 self.skipTest("buggy libc version") raise # len of every sequence is supposed to be == 5 for info in socket.getaddrinfo(HOST, None): self.asser... | 457,296 |
def connect(self, address): self.connected = False err = self.socket.connect_ex(address) # XXX Should interpret Winsock return values if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): return if err in (0, EISCONN): self.addr = address self.handle_connect_event() else: raise socket.error(err, errorcode[err]) | def connect(self, address): self.connected = False err = self.socket.connect_ex(address) # XXX Should interpret Winsock return valuesif err in (EINPROGRESS, EALREADY, EWOULDBLOCK) \ or err == EINVAL and os.name in ('nt', 'ce'): return if err in (0, EISCONN): self.addr = address self.handle_connect_event() else: raise s... | 457,297 |
def test_missing_import_source(self): # from import a tree = \ (257, (267, (268, (269, (281, (283, (1, 'from'), (1, 'import'), (286, (284, (1, 'fred')))))), (4, ''))), (4, ''), (0, '')) self.check_bad_tree(tree, "from import a") | def test_missing_import_source(self): # from import a tree = \ (257, (267, (268, (269, (281, (283, (1, 'from'), (1, 'import'), (286, (284, (1, 'fred')))))), (4, ''))), (4, ''), (0, '')) self.check_bad_tree(tree, "from import a") | 457,298 |
def test_missing_import_source(self): # from import a tree = \ (257, (267, (268, (269, (281, (283, (1, 'from'), (1, 'import'), (286, (284, (1, 'fred')))))), (4, ''))), (4, ''), (0, '')) self.check_bad_tree(tree, "from import a") | def test_missing_import_source(self): # from import a tree = \ (257, (268, (269, (270, (282, (284, (1, 'from'), (1, 'import'), (287, (285, (1, 'fred')))))), (4, ''))), (4, ''), (0, '')) self.check_bad_tree(tree, "from import a") | 457,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.