def test_main(): tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest, TestExceptions, BufferIOTest, BasicTCPTest2] if sys.platform != 'mac': tests.extend([ BasicUDPTest, UDPTimeoutTest ]) tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase, NetworkConnectionNoServer, NetworkConnectionAttributesTest, NetworkConnectionBehaviourTest, ]) if hasattr(socket, "socketpair"): tests.append(BasicSocketPairTest) if sys.platform == 'linux2': tests.append(TestLinuxAbstractNamespace) if isTipcAvailable(): tests.append(TIPCTest) tests.append(TIPCThreadableTest) thread_info = support.threading_setup() support.run_unittest(*tests) support.threading_cleanup(*thread_info)
def test_main(): tests = [TestPOP3Class, TestTimeouts, TestPOP3_SSLClass] thread_info = test_support.threading_setup() try: test_support.run_unittest(*tests) finally: test_support.threading_cleanup(*thread_info)
def test_main(): tests = [TestPOP3Class, TestTimeouts, TestPOP3_SSLClass, TestPOP3_TLSClass] thread_info = test_support.threading_setup() try: test_support.run_unittest(*tests) finally: test_support.threading_cleanup(*thread_info)
def test_main(self): threads = [] thread_info = threading_setup() for i in range(NUM_THREADS): t = TempFileGreedy() threads.append(t) t.start() startEvent.set() ok = 0 errors = [] for t in threads: t.join() ok += t.ok_count if t.error_count: errors.append(str(t.name) + str(t.errors.getvalue())) threading_cleanup(*thread_info) msg = "Errors: errors %d ok %d\n%s" % (len(errors), ok, '\n'.join(errors)) self.assertEqual(errors, [], msg) self.assertEqual(ok, NUM_THREADS * FILES_PER_THREAD)
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.pem") if (not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT)): raise support.TestFailed("Can't read certificate files!") tests = [BasicTests] if support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = support.threading_setup() if thread_info and support.is_resource_enabled('network'): tests.append(ThreadedTests) support.run_unittest(*tests) if _have_threads: support.threading_cleanup(*thread_info)
def tearDown(self): # Stop threads self.stop = 1 for thread in self.threads: thread.join() thread = None self.threads.clear() support.threading_cleanup(*self._threading_key)
def test_main(): tests = [TestFTPClass, TestTimeouts, TestIPv6Environment, TestTLS_FTPClassMixin, TestTLS_FTPClass] thread_info = support.threading_setup() try: support.run_unittest(*tests) finally: support.threading_cleanup(*thread_info)
def tearDown(self): self.client.close() self.evt.wait() # Disable server feedback DocXMLRPCServer._send_traceback_header = False support.threading_cleanup(*self._threads)
def tearDown(self): socket.getfqdn = self.real_getfqdn # indicate that the client is finished self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() self.thread.join() support.threading_cleanup(*self._threads)
def tearDown(self): try: os.remove(self.filename) except EnvironmentError as ee: # (Jython addition) detect failure common on Windows, on missing # close, that creates spurious errors in subsequent tests. if ee.errno != errno.ENOENT: raise ee support.threading_cleanup(*self._threads)
def test_main(): tests = [TestPOP3Class, TestTimeouts] if SUPPORTS_SSL: tests.append(TestPOP3_SSLClass) thread_info = test_support.threading_setup() try: test_support.run_unittest(*tests) finally: test_support.threading_cleanup(*thread_info)
def test_main(): tests = [ TestFTPClass, TestTimeouts, TestIPv6Environment, TestTLS_FTPClassMixin, TestTLS_FTPClass, MiscTestCase ] thread_info = support.threading_setup() try: support.run_unittest(*tests) finally: support.threading_cleanup(*thread_info)
def tearDown(self): self.unpatch_get_running_loop() events.set_event_loop(None) # Detect CPython bug #23353: ensure that yield/yield-from is not used # in an except block of a generator self.assertEqual(sys.exc_info(), (None, None, None)) self.doCleanups() support.threading_cleanup(*self._thread_cleanup) support.reap_children()
def tearDown(self): socket.getfqdn = self.real_getfqdn # indicate that the client is finished self.client_evt.set() # wait for the server thread to terminate self.serv_evt.wait() self.thread.join() support.threading_cleanup(*self._threads) # restore sys.stdout sys.stdout = self.old_stdout # restore DEBUGSTREAM smtpd.DEBUGSTREAM.close() smtpd.DEBUGSTREAM = self.old_DEBUGSTREAM
def tearDownModule(): support.threading_cleanup(*_threads_key) support.reap_children() # cleanup multiprocessing multiprocessing.process._cleanup() # Stop the ForkServer process if it's running from multiprocessing import forkserver forkserver._forkserver._stop() # bpo-37421: Explicitly call _run_finalizers() to remove immediately # temporary directories created by multiprocessing.util.get_temp_dir(). multiprocessing.util._run_finalizers() support.gc_collect()
def test_main(): tests = [TestFTPClass, TestTimeouts, TestNetrcDeprecation] if support.IPV6_ENABLED: tests.append(TestIPv6Environment) if ssl is not None: tests.extend([TestTLS_FTPClassMixin, TestTLS_FTPClass]) thread_info = support.threading_setup() try: support.run_unittest(*tests) finally: support.threading_cleanup(*thread_info)
def test_main(): tests = [TestFTPClass, TestTimeouts] if socket.has_ipv6: try: DummyFTPServer((HOST, 0), af=socket.AF_INET6) except socket.error: pass else: tests.append(TestIPv6Environment) thread_info = support.threading_setup() try: support.run_unittest(*tests) finally: support.threading_cleanup(*thread_info)
def tearDownModule(): if threads_key: support.threading_cleanup(*threads_key)
# Small Sample of using new features for ssl in Python 3.7 # Check if OpenSSL has built-in support for the TLS 1.3 protocol. if ssl.HAS_TLSv1_3: print("{0} with support for TLS 1.3".format(ssl.OPENSSL_VERSION)) # This example is based off of the unit test for bpo-32947 # written by # https://github.com/python/cpython/pull/5663/files CERTFILE = os.path.join(os.path.dirname(__file__), "keycert.pem") context = ssl.SSLContext(ssl.PROTOCOL_TLS) context.load_cert_chain(CERTFILE) context.options |= (ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1 | ssl.OP_NO_TLSv1_2) with ThreadedEchoServer(context=context) as server: with context.wrap_socket(socket.socket()) as s: s.connect(('localhost', server.port)) string = "TLS 1.3 Data" # Write data to the socket encoded as bytes s.sendall(str.encode(string)) # Block and read up to 512 bytes from the read buffer. data = s.recv(512) print("Decoded data: {0}".format(data.decode())) s.close() server.stop() thread_info = support.threading_setup() support.threading_cleanup(*thread_info)
def tearDown(self): self.thread.stop() self.thread = None os.environ.__exit__() support.threading_cleanup(*self._threads)
def tearDown(self): support.threading_cleanup(*self._threads) support.reap_children()
def tearDown(self): support.threading_cleanup(*self._threads)
def tearDown (self): support.threading_cleanup(*self._threads)
def tearDownModule(): support.threading_cleanup(*_threads_key) multiprocessing.util._cleanup_tests()