当前位置: 首页>>代码示例>>Python>>正文


Python test_support.verbose方法代码示例

本文整理汇总了Python中test.test_support.verbose方法的典型用法代码示例。如果您正苦于以下问题:Python test_support.verbose方法的具体用法?Python test_support.verbose怎么用?Python test_support.verbose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test.test_support的用法示例。


在下文中一共展示了test_support.verbose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_import_hangers

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def test_import_hangers():
    import sys
    if verbose:
        print "testing import hangers ...",

    import test.threaded_import_hangers
    try:
        if test.threaded_import_hangers.errors:
            raise TestFailed(test.threaded_import_hangers.errors)
        elif verbose:
            print "OK."
    finally:
        # In case this test is run again, make sure the helper module
        # gets loaded from scratch again.
        del sys.modules['test.threaded_import_hangers']

# Tricky:  When regrtest imports this module, the thread running regrtest
# grabs the import lock and won't let go of it until this module returns.
# All other threads attempting an import hang for the duration.  Since
# this test spawns threads that do little *but* import, we can't do that
# successfully until after this module finishes importing and regrtest
# regains control.  To make this work, a special case was added to
# regrtest to invoke a module's "test_main" function (if any) after
# importing it. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:test_threaded_import.py

示例2: test_main

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def test_main():        # magic name!  see above
    global N, done

    import imp
    if imp.lock_held():
        # This triggers on, e.g., from test import autotest.
        raise unittest.SkipTest("can't run when import lock is held")

    done.acquire()
    for N in (20, 50) * 3:
        if verbose:
            print "Trying", N, "threads ...",
        for i in range(N):
            thread.start_new_thread(task, ())
        done.acquire()
        if verbose:
            print "OK."
    done.release()

    test_import_hangers() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_threaded_import.py

示例3: sig_vtalrm

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def sig_vtalrm(self, *args):
        self.hndl_called = True

        if self.hndl_count > 3:
            # it shouldn't be here, because it should have been disabled.
            raise signal.ItimerError("setitimer didn't disable ITIMER_VIRTUAL "
                "timer.")
        elif self.hndl_count == 3:
            # disable ITIMER_VIRTUAL, this function shouldn't be called anymore
            signal.setitimer(signal.ITIMER_VIRTUAL, 0)
            if test_support.verbose:
                print("last SIGVTALRM handler call")

        self.hndl_count += 1

        if test_support.verbose:
            print("SIGVTALRM handler invoked", args) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_signal.py

示例4: run

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def run(self):
        delay = random.random() / 10000.0
        if verbose:
            print 'task %s will run for %.1f usec' % (
                self.name, delay * 1e6)

        with self.sema:
            with self.mutex:
                self.nrunning.inc()
                if verbose:
                    print self.nrunning.get(), 'tasks are running'
                self.testcase.assertLessEqual(self.nrunning.get(), 3)

            time.sleep(delay)
            if verbose:
                print 'task', self.name, 'done'

            with self.mutex:
                self.nrunning.dec()
                self.testcase.assertGreaterEqual(self.nrunning.get(), 0)
                if verbose:
                    print '%s is finished. %d tasks are running' % (
                        self.name, self.nrunning.get()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_threading.py

示例5: test_strftime

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def test_strftime(self):
        now = time.time()
        self._update_variables(now)
        self.strftest1(now)
        self.strftest2(now)

        if test_support.verbose:
            print "Strftime test, platform: %s, Python version: %s" % \
                  (sys.platform, sys.version.split()[0])

        for j in range(-5, 5):
            for i in range(25):
                arg = now + (i+j*100)*23*3603
                self._update_variables(arg)
                self.strftest1(arg)
                self.strftest2(arg) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_strftime.py

示例6: _run_workers

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def _run_workers(self, func, nb_workers, duration=0.2):
        with self._count_lock:
            self.close_count = 0
            self.close_success_count = 0
        self.do_continue = True
        threads = []
        try:
            for i in range(nb_workers):
                t = threading.Thread(target=func)
                t.start()
                threads.append(t)
            for _ in xrange(100):
                time.sleep(duration/100)
                with self._count_lock:
                    if self.close_count-self.close_success_count > nb_workers+1:
                        if test_support.verbose:
                            print 'Q',
                        break
            time.sleep(duration)
        finally:
            self.do_continue = False
            for t in threads:
                t.join() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_file2k.py

示例7: _test_close_open_io

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def _test_close_open_io(self, io_func, nb_workers=5):
        def worker():
            self._create_file()
            funcs = itertools.cycle((
                lambda: io_func(),
                lambda: self._close_and_reopen_file(),
            ))
            for f in funcs:
                if not self.do_continue:
                    break
                try:
                    f()
                except (IOError, ValueError):
                    pass
        self._run_workers(worker, nb_workers)
        if test_support.verbose:
            # Useful verbose statistics when tuning this test to take
            # less time to run but still ensuring that its still useful.
            #
            # the percent of close calls that raised an error
            percent = 100. - 100.*self.close_success_count/self.close_count
            print self.close_count, ('%.4f ' % percent), 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_file2k.py

示例8: test_main

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def test_main(verbose=None):
    test_classes = (
        TestBase,
        TestDecorateSortUndecorate,
        TestBugs,
    )

    with test_support.check_py3k_warnings(
            ("the cmp argument is not supported", DeprecationWarning)):
        test_support.run_unittest(*test_classes)

        # verify reference counting
        if verbose and hasattr(sys, "gettotalrefcount"):
            import gc
            counts = [None] * 5
            for i in xrange(len(counts)):
                test_support.run_unittest(*test_classes)
                gc.collect()
                counts[i] = sys.gettotalrefcount()
            print counts 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_sort.py

示例9: make_server

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def make_server(self, addr, svrcls, hdlrbase):
        class MyServer(svrcls):
            def handle_error(self, request, client_address):
                self.close_request(request)
                close_server(self)
                raise

        class MyHandler(hdlrbase):
            def handle(self):
                line = self.rfile.readline()
                self.wfile.write(line)

        if verbose: print "creating server"
        server = MyServer(addr, MyHandler)
        self.assertEqual(server.server_address, server.socket.getsockname())
        return server 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_socketserver.py

示例10: test_non_blocking_handshake

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def test_non_blocking_handshake(self):
        with support.transient_internet(REMOTE_HOST):
            s = socket.socket(socket.AF_INET)
            s.connect((REMOTE_HOST, 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.SSLWantReadError:
                    select.select([s], [], [])
                except ssl.SSLWantWriteError:
                    select.select([], [s], [])
            s.close()
            if support.verbose:
                sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:test_ssl.py

示例11: test_protocol_sslv3

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def test_protocol_sslv3(self):
            """Connecting to an SSLv3 server with various client options"""
            if support.verbose:
                sys.stdout.write("\n")
            try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, 'SSLv3')
            try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, 'SSLv3', ssl.CERT_OPTIONAL)
            try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, 'SSLv3', ssl.CERT_REQUIRED)
            if hasattr(ssl, 'PROTOCOL_SSLv2'):
                try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False)
            try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False,
                               client_options=ssl.OP_NO_SSLv3)
            try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False)
            if no_sslv2_implies_sslv3_hello():
                # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs
                try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23,
                                   False, client_options=ssl.OP_NO_SSLv2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_ssl.py

示例12: test_protocol_tlsv1_1

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def test_protocol_tlsv1_1(self):
            """Connecting to a TLSv1.1 server with various client options.
               Testing against older TLS versions."""
            if support.verbose:
                sys.stdout.write("\n")
            try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1_1, 'TLSv1.1')
            if hasattr(ssl, 'PROTOCOL_SSLv2'):
                try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv2, False)
            if hasattr(ssl, 'PROTOCOL_SSLv3'):
                try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv3, False)
            try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_SSLv23, False,
                               client_options=ssl.OP_NO_TLSv1_1)

            try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1_1, 'TLSv1.1')
            try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1, False)
            try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_1, False) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_ssl.py

示例13: test_protocol_tlsv1_2

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def test_protocol_tlsv1_2(self):
            """Connecting to a TLSv1.2 server with various client options.
               Testing against older TLS versions."""
            if support.verbose:
                sys.stdout.write("\n")
            try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1_2, 'TLSv1.2',
                               server_options=ssl.OP_NO_SSLv3|ssl.OP_NO_SSLv2,
                               client_options=ssl.OP_NO_SSLv3|ssl.OP_NO_SSLv2,)
            if hasattr(ssl, 'PROTOCOL_SSLv2'):
                try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv2, False)
            if hasattr(ssl, 'PROTOCOL_SSLv3'):
                try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv3, False)
            try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv23, False,
                               client_options=ssl.OP_NO_TLSv1_2)

            try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1_2, 'TLSv1.2')
            try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1, False)
            try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_2, False)
            try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_TLSv1_1, False)
            try_protocol_combo(ssl.PROTOCOL_TLSv1_1, ssl.PROTOCOL_TLSv1_2, False) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_ssl.py

示例14: test_socketserver

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def test_socketserver(self):
            """Using a SocketServer to create and manage SSL connections."""
            server = make_https_server(self, certfile=CERTFILE)
            # try to connect
            if support.verbose:
                sys.stdout.write('\n')
            with open(CERTFILE, 'rb') as f:
                d1 = f.read()
            d2 = ''
            # now fetch the same data from the HTTPS server
            url = 'https://localhost:%d/%s' % (
                server.port, os.path.split(CERTFILE)[1])
            context = ssl.create_default_context(cafile=CERTFILE)
            f = urllib2.urlopen(url, context=context)
            try:
                dlen = f.info().getheader("content-length")
                if dlen and (int(dlen) > 0):
                    d2 = f.read(int(dlen))
                    if support.verbose:
                        sys.stdout.write(
                            " client: read %d bytes from remote server '%s'\n"
                            % (len(d2), server))
            finally:
                f.close()
            self.assertEqual(d1, d2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:test_ssl.py

示例15: run

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import verbose [as 别名]
def run(self):
            global running
            global sema
            global mutex
            # Uncomment if testing another module, such as the real 'threading'
            # module.
            #delay = random.random() * 2
            delay = 0
            if test_support.verbose:
                print 'task', self.name, 'will run for', delay, 'sec'
            sema.acquire()
            mutex.acquire()
            running += 1
            if test_support.verbose:
                print running, 'tasks are running'
            mutex.release()
            time.sleep(delay)
            if test_support.verbose:
                print 'task', self.name, 'done'
            mutex.acquire()
            running -= 1
            if test_support.verbose:
                print self.name, 'is finished.', running, 'tasks are running'
            mutex.release()
            sema.release() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:27,代码来源:test_dummy_threading.py


注:本文中的test.test_support.verbose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。