Python test.test_support.threading_setup() Examples
The following are 30
code examples of test.test_support.threading_setup().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
test.test_support
, or try the search function
.
Example #1
Source File: test_smtplib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def setUp(self): # temporarily replace sys.stdout to capture DebuggingServer output self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear()
Example #2
Source File: test_threadedtempfile.py From oss-ftp with MIT License | 6 votes |
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.getName()) + 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)
Example #3
Source File: test_ftplib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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) if ssl is not None: tests.extend([TestTLS_FTPClassMixin, TestTLS_FTPClass]) thread_info = test_support.threading_setup() try: test_support.run_unittest(*tests) finally: test_support.threading_cleanup(*thread_info)
Example #4
Source File: test_socket.py From oss-ftp with MIT License | 6 votes |
def test_main(): tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest, TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ] tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, FileObjectInterruptedTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase, Urllib2FileobjectTest, NetworkConnectionNoServer, NetworkConnectionAttributesTest, NetworkConnectionBehaviourTest, ]) tests.append(BasicSocketPairTest) tests.append(TestLinuxAbstractNamespace) tests.extend([TIPCTest, TIPCThreadableTest]) thread_info = test_support.threading_setup() test_support.run_unittest(*tests) test_support.threading_cleanup(*thread_info)
Example #5
Source File: test_threadedtempfile.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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.getName()) + 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)
Example #6
Source File: test_smtplib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def setUp(self): # temporarily replace sys.stdout to capture DebuggingServer output self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear()
Example #7
Source File: test_smtplib.py From oss-ftp with MIT License | 6 votes |
def setUp(self): # temporarily replace sys.stdout to capture DebuggingServer output self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear()
Example #8
Source File: test_smtplib.py From BinderFilter with MIT License | 6 votes |
def setUp(self): # temporarily replace sys.stdout to capture DebuggingServer output self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear()
Example #9
Source File: test_threadedtempfile.py From BinderFilter with MIT License | 6 votes |
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.getName()) + 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)
Example #10
Source File: test_ftplib.py From BinderFilter with MIT License | 6 votes |
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) if ssl is not None: tests.extend([TestTLS_FTPClassMixin, TestTLS_FTPClass]) thread_info = test_support.threading_setup() try: test_support.run_unittest(*tests) finally: test_support.threading_cleanup(*thread_info)
Example #11
Source File: test_ftplib.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
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) if ssl is not None: tests.extend([TestTLS_FTPClassMixin, TestTLS_FTPClass]) thread_info = test_support.threading_setup() try: test_support.run_unittest(*tests) finally: test_support.threading_cleanup(*thread_info)
Example #12
Source File: test_threadedtempfile.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
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.getName()) + 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)
Example #13
Source File: test_smtplib.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def setUp(self): # temporarily replace sys.stdout to capture DebuggingServer output self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear()
Example #14
Source File: test_threadedtempfile.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
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.getName()) + 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)
Example #15
Source File: test_smtplib.py From ironpython2 with Apache License 2.0 | 6 votes |
def setUp(self): # temporarily replace sys.stdout to capture DebuggingServer output self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear()
Example #16
Source File: test_socket.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_main(): tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest, TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ] tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, FileObjectInterruptedTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase, Urllib2FileobjectTest, NetworkConnectionNoServer, NetworkConnectionAttributesTest, NetworkConnectionBehaviourTest, ]) tests.append(BasicSocketPairTest) tests.append(TestLinuxAbstractNamespace) tests.extend([TIPCTest, TIPCThreadableTest]) thread_info = test_support.threading_setup() test_support.run_unittest(*tests) test_support.threading_cleanup(*thread_info)
Example #17
Source File: test_socket.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_main(): tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest, TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ] tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, FileObjectInterruptedTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase, Urllib2FileobjectTest, NetworkConnectionNoServer, NetworkConnectionAttributesTest, NetworkConnectionBehaviourTest, ]) tests.append(BasicSocketPairTest) tests.append(TestLinuxAbstractNamespace) tests.extend([TIPCTest, TIPCThreadableTest]) thread_info = test_support.threading_setup() test_support.run_unittest(*tests) test_support.threading_cleanup(*thread_info)
Example #18
Source File: lock_tests.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def setUp(self): self._threads = support.threading_setup()
Example #19
Source File: test_file2k.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def setUp(self): self._threads = test_support.threading_setup() self.filename = TESTFN self.exc_info = None with open(self.filename, "w") as f: f.write("\n".join("0123456789")) self._count_lock = threading.Lock() self.close_count = 0 self.close_success_count = 0 self.use_buffering = False
Example #20
Source File: test_urllib2_localnet.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def setUp(self): self._threads = test_support.threading_setup()
Example #21
Source File: test_smtplib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def setUp(self): self.old_stdout = sys.stdout self.output = StringIO.StringIO() sys.stdout = self.output self._threads = test_support.threading_setup() self.evt = threading.Event() self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.settimeout(15) self.port = test_support.bind_port(self.sock) servargs = (self.evt, "199 no hello for you!\n", self.sock) self.thread = threading.Thread(target=server, args=servargs) self.thread.start() self.evt.wait() self.evt.clear()
Example #22
Source File: test_smtplib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp(self): self._threads = test_support.threading_setup() self.serv_evt = threading.Event() self.client_evt = threading.Event() # Pick a random unused port by passing 0 for the port number self.serv = SimSMTPServer((HOST, 0), ('nowhere', -1)) # Keep a note of what port was assigned self.port = self.serv.socket.getsockname()[1] serv_args = (self.serv, self.serv_evt, self.client_evt) self.thread = threading.Thread(target=debugging_server, args=serv_args) self.thread.start() # wait until server thread has assigned a port number self.serv_evt.wait() self.serv_evt.clear()
Example #23
Source File: test_threadedtempfile.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_main(): threads = [] thread_info = threading_setup() print "Creating" for i in range(NUM_THREADS): t = TempFileGreedy() threads.append(t) t.start() print "Starting" startEvent.set() print "Reaping" ok = errors = 0 for t in threads: t.join() ok += t.ok_count errors += t.error_count if t.error_count: print '%s errors:\n%s' % (t.getName(), t.errors.getvalue()) msg = "Done: errors %d ok %d" % (errors, ok) print msg if errors: raise TestFailed(msg) threading_cleanup(*thread_info)
Example #24
Source File: test_asynchat.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp (self): self._threads = test_support.threading_setup()
Example #25
Source File: test_docxmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp(self): self._threads = test_support.threading_setup() # Enable server feedback DocXMLRPCServer._send_traceback_header = True self.evt = threading.Event() threading.Thread(target=server, args=(self.evt, 1)).start() # wait for port to be assigned n = 1000 while n > 0 and PORT is None: time.sleep(0.001) n -= 1 self.client = httplib.HTTPConnection("localhost:%d" % PORT)
Example #26
Source File: test_poplib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #27
Source File: test_ssl.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_main(verbose=False): global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT, NULLBYTECERT 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") NOKIACERT = os.path.join(os.path.dirname(__file__) or os.curdir, "nokia.pem") NULLBYTECERT = os.path.join(os.path.dirname(__file__) or os.curdir, "nullbytecert.pem") if (not os.path.exists(CERTFILE) or not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT) or not os.path.exists(NOKIACERT) or not os.path.exists(NULLBYTECERT)): raise test_support.TestFailed("Can't read certificate files!") tests = [BasicTests, BasicSocketTests] if test_support.is_resource_enabled('network'): tests.append(NetworkedTests) if _have_threads: thread_info = test_support.threading_setup() if thread_info and test_support.is_resource_enabled('network'): tests.append(ThreadedTests) try: test_support.run_unittest(*tests) finally: if _have_threads: test_support.threading_cleanup(*thread_info)
Example #28
Source File: test_urllib2_localnet.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp(self): self._threads = test_support.threading_setup()
Example #29
Source File: lock_tests.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp(self): self._threads = support.threading_setup()
Example #30
Source File: test_file2k.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUp(self): self._threads = test_support.threading_setup() self.f = None self.filename = TESTFN with open(self.filename, "w") as f: f.write("\n".join("0123456789")) self._count_lock = threading.Lock() self.close_count = 0 self.close_success_count = 0 self.use_buffering = False