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


Python test_support._check_py3k_warnings函数代码示例

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


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

示例1: test_basic_proxy

    def test_basic_proxy(self):
        o = C()
        self.check_proxy(o, weakref.proxy(o))

        L = UserList.UserList()
        p = weakref.proxy(L)
        self.failIf(p, "proxy for empty UserList should be false")
        p.append(12)
        self.assertEqual(len(L), 1)
        self.failUnless(p, "proxy for non-empty UserList should be true")
        with test_support._check_py3k_warnings():
            p[:] = [2, 3]
        self.assertEqual(len(L), 2)
        self.assertEqual(len(p), 2)
        self.failUnless(3 in p, "proxy didn't support __contains__() properly")
        p[1] = 5
        self.assertEqual(L[1], 5)
        self.assertEqual(p[1], 5)
        L2 = UserList.UserList(L)
        p2 = weakref.proxy(L2)
        self.assertEqual(p, p2)
        ## self.assertEqual(repr(L2), repr(p2))
        L3 = UserList.UserList(range(10))
        p3 = weakref.proxy(L3)
        with test_support._check_py3k_warnings():
            self.assertEqual(L3[:], p3[:])
            self.assertEqual(L3[5:], p3[5:])
            self.assertEqual(L3[:5], p3[:5])
            self.assertEqual(L3[2:5], p3[2:5])
开发者ID:fabianonunes,项目名称:plone-4.1,代码行数:29,代码来源:test_weakref.py

示例2: test_socketserver

 def test_socketserver(self):
     """Using a SocketServer to create and manage SSL connections."""
     server = SocketServerHTTPSServer(CERTFILE)
     flag = threading.Event()
     server.start(flag)
     # wait for it to start
     flag.wait()
     # try to connect
     try:
         if test_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://127.0.0.1:%d/%s" % (server.port, os.path.split(CERTFILE)[1])
         with test_support._check_py3k_warnings():
             f = urllib.urlopen(url)
         dlen = f.info().getheader("content-length")
         if dlen and (int(dlen) > 0):
             d2 = f.read(int(dlen))
             if test_support.verbose:
                 sys.stdout.write(" client: read %d bytes from remote server '%s'\n" % (len(d2), server))
         f.close()
         self.assertEqual(d1, d2)
     finally:
         server.stop()
         server.join()
开发者ID:exodrifter,项目名称:unity-python,代码行数:28,代码来源:test_ssl.py

示例3: testComplexDefinitions

    def testComplexDefinitions(self):

        def makeReturner(*lst):
            def returner():
                return lst
            return returner

        self.assertEqual(makeReturner(1,2,3)(), (1,2,3))

        def makeReturner2(**kwargs):
            def returner():
                return kwargs
            return returner

        self.assertEqual(makeReturner2(a=11)()['a'], 11)

        with _check_py3k_warnings(("tuple parameter unpacking has been removed",
                                  SyntaxWarning)):
            exec """\
def makeAddPair((a, b)):
    def addPair((c, d)):
        return (a + c, b + d)
    return addPair
""" in locals()
        self.assertEqual(makeAddPair((1, 2))((100, 200)), (101,202))
开发者ID:DecipherOne,项目名称:Troglodyte,代码行数:25,代码来源:test_scope.py

示例4: test_main

def test_main():
    with _check_py3k_warnings(("buffer.. not supported", DeprecationWarning),
                              ("classic (int|long) division", DeprecationWarning),):
        import ctypes.test
        skipped, testcases = ctypes.test.get_tests(ctypes.test, "test_*.py", verbosity=0)
        suites = [unittest.makeSuite(t) for t in testcases]
        run_unittest(unittest.TestSuite(suites))
开发者ID:AojiaoZero,项目名称:CrossApp,代码行数:7,代码来源:test_ctypes.py

示例5: testMethods

    def testMethods(self):
        methods = ['fileno', 'flush', 'isatty', 'next', 'read', 'readinto',
                   'readline', 'readlines', 'seek', 'tell', 'truncate',
                   'write', 'xreadlines', '__iter__']
        if sys.platform.startswith('atheos'):
            methods.remove('truncate')

        # __exit__ should close the file
        self.f.__exit__(None, None, None)
        self.assert_(self.f.closed)

        for methodname in methods:
            method = getattr(self.f, methodname)
            # should raise on closed file
            with test_support._check_py3k_warnings(quiet=True):
                self.assertRaises(ValueError, method)
        self.assertRaises(ValueError, self.f.writelines, [])

        # file is closed, __exit__ shouldn't do anything
        self.assertEquals(self.f.__exit__(None, None, None), None)
        # it must also return None if an exception was given
        try:
            1 // 0
        except:
            self.assertEquals(self.f.__exit__(*sys.exc_info()), None)
开发者ID:DecipherOne,项目名称:Troglodyte,代码行数:25,代码来源:test_file.py

示例6: test_main

def test_main():
    with _check_py3k_warnings(("exceptions must derive from BaseException",
                              DeprecationWarning),
                             ("catching classes that don't inherit "
                              "from BaseException is not allowed",
                              DeprecationWarning)):
        run_unittest(OpcodeTest)
开发者ID:DecipherOne,项目名称:Troglodyte,代码行数:7,代码来源:test_opcodes.py

示例7: test_builtin_map

    def test_builtin_map(self):
        self.assertEqual(map(lambda x: x + 1, SequenceClass(5)), range(1, 6))

        d = {"one": 1, "two": 2, "three": 3}
        self.assertEqual(map(lambda k, d=d: (k, d[k]), d), d.items())
        dkeys = d.keys()
        expected = [(i < len(d) and dkeys[i] or None, i, i < len(d) and dkeys[i] or None) for i in range(5)]

        # Deprecated map(None, ...)
        with _check_py3k_warnings():
            self.assertEqual(map(None, SequenceClass(5)), range(5))
            self.assertEqual(map(None, d), d.keys())
            self.assertEqual(map(None, d, SequenceClass(5), iter(d.iterkeys())), expected)

        f = open(TESTFN, "w")
        try:
            for i in range(10):
                f.write("xy" * i + "\n")  # line i has len 2*i+1
        finally:
            f.close()
        f = open(TESTFN, "r")
        try:
            self.assertEqual(map(len, f), range(1, 21, 2))
        finally:
            f.close()
            try:
                unlink(TESTFN)
            except OSError:
                pass
开发者ID:fabianonunes,项目名称:plone-4.1,代码行数:29,代码来源:test_iter.py

示例8: test_main

def test_main():
    test_support.requires('network')
    with test_support._check_py3k_warnings(
            ("urllib.urlopen.. has been removed", DeprecationWarning)):
        test_support.run_unittest(URLTimeoutTest,
                                  urlopenNetworkTests,
                                  urlretrieveNetworkTests)
开发者ID:DecipherOne,项目名称:Troglodyte,代码行数:7,代码来源:test_urllibnet.py

示例9: test_execfile

 def test_execfile(self):
     namespace = {}
     with test_support._check_py3k_warnings():
         execfile(test_support.TESTFN, namespace)
     func = namespace['line3']
     self.assertEqual(func.func_code.co_firstlineno, 3)
     self.assertEqual(namespace['line4'], FATX)
开发者ID:DecipherOne,项目名称:Troglodyte,代码行数:7,代码来源:test_univnewlines.py

示例10: test_main

def test_main():
    with _check_py3k_warnings(
            ("backquote not supported", SyntaxWarning),
            ("tuple parameter unpacking has been removed", SyntaxWarning),
            ("parenthesized argument names are invalid", SyntaxWarning),
            ("classic int division", DeprecationWarning),
            (".+ not supported in 3.x", DeprecationWarning)):
        run_unittest(TokenTests, GrammarTests)
开发者ID:DecipherOne,项目名称:Troglodyte,代码行数:8,代码来源:test_grammar.py

示例11: test_varargs2_ext

 def test_varargs2_ext(self):
     try:
         with test_support._check_py3k_warnings():
             {}.has_key(*(1, 2))
     except TypeError:
         pass
     else:
         raise RuntimeError
开发者ID:DecipherOne,项目名称:Troglodyte,代码行数:8,代码来源:test_call.py

示例12: test_main

def test_main():
    with test_support._check_py3k_warnings(
        ('dict(.has_key..| inequality comparisons) not supported in 3.x',
         DeprecationWarning)):
        test_support.run_unittest(
            DictTest,
            GeneralMappingTests,
            SubclassMappingTests,
        )
开发者ID:AojiaoZero,项目名称:CrossApp,代码行数:9,代码来源:test_dict.py

示例13: test_getargspec_sublistofone

    def test_getargspec_sublistofone(self):
        with _check_py3k_warnings(
                ("tuple parameter unpacking has been removed", SyntaxWarning),
                ("parenthesized argument names are invalid", SyntaxWarning)):
            exec 'def sublistOfOne((foo,)): return 1'
            self.assertArgSpecEquals(sublistOfOne, [['foo']])

            exec 'def fakeSublistOfOne((foo)): return 1'
            self.assertArgSpecEquals(fakeSublistOfOne, ['foo'])
开发者ID:nakagami,项目名称:jython3,代码行数:9,代码来源:test_inspect.py

示例14: test_setslice_without_getslice

    def test_setslice_without_getslice(self):
        tmp = []
        class X(object):
            def __setslice__(self, i, j, k):
                tmp.append((i, j, k))

        x = X()
        with test_support._check_py3k_warnings():
            x[1:2] = 42
        self.assertEquals(tmp, [(1, 2, 42)])
开发者ID:DecipherOne,项目名称:Troglodyte,代码行数:10,代码来源:test_slice.py

示例15: test_unpack_with_buffer

    def test_unpack_with_buffer(self):
        with _check_py3k_warnings(("buffer.. not supported in 3.x",
                                  DeprecationWarning)):
            # SF bug 1563759: struct.unpack doesn't support buffer protocol objects
            data1 = array.array('B', '\x12\x34\x56\x78')
            data2 = buffer('......\x12\x34\x56\x78......', 6, 4)
            for data in [data1, data2]:
                value, = struct.unpack('>I', data)
                self.assertEqual(value, 0x12345678)

            self.test_unpack_from(cls=buffer)
开发者ID:AojiaoZero,项目名称:CrossApp,代码行数:11,代码来源:test_struct.py


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