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


Python test_support.check_py3k_warnings方法代码示例

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


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

示例1: setUp

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def setUp(self):
        self.con = sqlite.connect(":memory:")
        cur = self.con.cursor()
        cur.execute("""
            create table test(
                t text,
                i integer,
                f float,
                n,
                b blob
                )
            """)
        with test_support.check_py3k_warnings():
            cur.execute("insert into test(t, i, f, n, b) values (?, ?, ?, ?, ?)",
                ("foo", 5, 3.14, None, buffer("blob"),))

        self.con.create_aggregate("nostep", 1, AggrNoStep)
        self.con.create_aggregate("nofinalize", 1, AggrNoFinalize)
        self.con.create_aggregate("excInit", 1, AggrExceptionInInit)
        self.con.create_aggregate("excStep", 1, AggrExceptionInStep)
        self.con.create_aggregate("excFinalize", 1, AggrExceptionInFinalize)
        self.con.create_aggregate("checkType", 2, AggrCheckType)
        self.con.create_aggregate("mysum", 1, AggrSum) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:userfunctions.py

示例2: testAttributes

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def testAttributes(self):
        # verify expected attributes exist
        f = self.f
        with test_support.check_py3k_warnings():
            softspace = f.softspace
        f.name     # merely shouldn't blow up
        f.mode     # ditto
        f.closed   # ditto

        with test_support.check_py3k_warnings():
            # verify softspace is writable
            f.softspace = softspace    # merely shouldn't blow up

        # verify the others aren't
        for attr in 'name', 'mode', 'closed':
            self.assertRaises((AttributeError, TypeError), setattr, f, attr, 'oops') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_file2k.py

示例3: test_main

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

    with test_support.check_py3k_warnings(
            ("backquote not supported", SyntaxWarning)):
        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,代码行数:20,代码来源:test_peepholer.py

示例4: test_issue_12717

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def test_issue_12717(self):
        d1 = dict(red=1, green=2)
        d2 = dict(green=3, blue=4)
        dcomb = d2.copy()
        dcomb.update(d1)
        cm = ConfigParser._Chainmap(d1, d2)
        self.assertIsInstance(cm.keys(), list)
        self.assertEqual(set(cm.keys()), set(dcomb.keys()))      # keys()
        self.assertEqual(set(cm.values()), set(dcomb.values()))  # values()
        self.assertEqual(set(cm.items()), set(dcomb.items()))    # items()
        self.assertEqual(set(cm), set(dcomb))                    # __iter__ ()
        self.assertEqual(cm, dcomb)                              # __eq__()
        self.assertEqual([cm[k] for k in dcomb], dcomb.values()) # __getitem__()
        klist = 'red green blue black brown'.split()
        self.assertEqual([cm.get(k, 10) for k in klist],
                         [dcomb.get(k, 10) for k in klist])      # get()
        self.assertEqual([k in cm for k in klist],
                         [k in dcomb for k in klist])            # __contains__()
        with test_support.check_py3k_warnings():
            self.assertEqual([cm.has_key(k) for k in klist],
                             [dcomb.has_key(k) for k in klist])  # has_key() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:test_cfgparser.py

示例5: test_builtin_function_or_method_comparisons

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def test_builtin_function_or_method_comparisons(self):
        expected = ('builtin_function_or_method '
                    'order comparisons not supported in 3.x')
        func = eval
        meth = {}.get
        with check_py3k_warnings() as w:
            self.assertWarning(func < meth, w, expected)
            w.reset()
            self.assertWarning(func > meth, w, expected)
            w.reset()
            self.assertWarning(meth <= func, w, expected)
            w.reset()
            self.assertWarning(meth >= func, w, expected)
            w.reset()
            self.assertNoWarning(meth == func, w)
            self.assertNoWarning(meth != func, w)
            lam = lambda x: x
            self.assertNoWarning(lam == func, w)
            self.assertNoWarning(lam != func, w) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:test_py3kwarn.py

示例6: test_slice_methods

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def test_slice_methods(self):
        class Spam(object):
            def __getslice__(self, i, j): pass
            def __setslice__(self, i, j, what): pass
            def __delslice__(self, i, j): pass
        class Egg:
            def __getslice__(self, i, h): pass
            def __setslice__(self, i, j, what): pass
            def __delslice__(self, i, j): pass

        expected = "in 3.x, __{0}slice__ has been removed; use __{0}item__"

        for obj in (Spam(), Egg()):
            with check_py3k_warnings() as w:
                self.assertWarning(obj[1:2], w, expected.format('get'))
                w.reset()
                del obj[3:4]
                self.assertWarning(None, w, expected.format('del'))
                w.reset()
                obj[4:5] = "eggs"
                self.assertWarning(None, w, expected.format('set')) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:test_py3kwarn.py

示例7: test_w_star

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def test_w_star(self):
        # getargs_w_star() modifies first and last byte
        from _testcapi import getargs_w_star
        self.assertRaises(TypeError, getargs_w_star, 'abc')
        self.assertRaises(TypeError, getargs_w_star, u'abc')
        self.assertRaises(TypeError, getargs_w_star, memoryview('bytes'))
        buf = bytearray('bytearray')
        self.assertEqual(getargs_w_star(buf), '[ytearra]')
        self.assertEqual(buf, bytearray('[ytearra]'))
        buf = bytearray(b'memoryview')
        self.assertEqual(getargs_w_star(memoryview(buf)), '[emoryvie]')
        self.assertEqual(buf, bytearray('[emoryvie]'))
        with test_support.check_py3k_warnings():
            self.assertRaises(TypeError, getargs_w_star, buffer('buffer'))
            self.assertRaises(TypeError, getargs_w_star,
                              buffer(bytearray('buffer')))
        self.assertRaises(TypeError, getargs_w_star, None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_getargs2.py

示例8: test_es

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def test_es(self):
        from _testcapi import getargs_es
        self.assertEqual(getargs_es('abc'), 'abc')
        self.assertEqual(getargs_es(u'abc'), 'abc')
        self.assertEqual(getargs_es('abc', 'ascii'), 'abc')
        self.assertEqual(getargs_es(u'abc\xe9', 'latin1'), 'abc\xe9')
        self.assertRaises(UnicodeEncodeError, getargs_es, u'abc\xe9', 'ascii')
        self.assertRaises(LookupError, getargs_es, u'abc', 'spam')
        self.assertRaises(TypeError, getargs_es,
                          bytearray('bytearray'), 'latin1')
        self.assertRaises(TypeError, getargs_es,
                          memoryview('memoryview'), 'latin1')
        with test_support.check_py3k_warnings():
            self.assertEqual(getargs_es(buffer('abc'), 'ascii'), 'abc')
            self.assertEqual(getargs_es(buffer(u'abc'), 'ascii'), 'abc')
        self.assertRaises(TypeError, getargs_es, None, 'latin1')
        self.assertRaises(TypeError, getargs_es, 'nul:\0', 'latin1')
        self.assertRaises(TypeError, getargs_es, u'nul:\0', 'latin1') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_getargs2.py

示例9: CheckBinary

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def CheckBinary(self):
        with test_support.check_py3k_warnings():
            b = sqlite.Binary(chr(0) + "'") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:dbapi.py

示例10: func_returnblob

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def func_returnblob():
    with test_support.check_py3k_warnings():
        return buffer("blob") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:userfunctions.py

示例11: CheckFuncReturnBlob

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def CheckFuncReturnBlob(self):
        cur = self.con.cursor()
        cur.execute("select returnblob()")
        val = cur.fetchone()[0]
        with test_support.check_py3k_warnings():
            self.assertEqual(type(val), buffer)
            self.assertEqual(val, buffer("blob")) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:userfunctions.py

示例12: CheckParamBlob

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def CheckParamBlob(self):
        cur = self.con.cursor()
        with test_support.check_py3k_warnings():
            cur.execute("select isblob(?)", (buffer("blob"),))
        val = cur.fetchone()[0]
        self.assertEqual(val, 1) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:userfunctions.py

示例13: CheckBlob

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def CheckBlob(self):
        with test_support.check_py3k_warnings():
            val = buffer("Guglhupf")
        self.cur.execute("insert into test(b) values (?)", (val,))
        self.cur.execute("select b from test")
        row = self.cur.fetchone()
        self.assertEqual(row[0], val) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:types.py

示例14: CheckBinaryInputForConverter

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def CheckBinaryInputForConverter(self):
        testdata = "abcdefg" * 10
        with test_support.check_py3k_warnings():
            result = self.con.execute('select ? as "x [bin]"', (buffer(zlib.compress(testdata)),)).fetchone()[0]
        self.assertEqual(testdata, result) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:types.py

示例15: test_c_buffer_deprecated

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_py3k_warnings [as 别名]
def test_c_buffer_deprecated(self):
        # Compatibility with 2.x
        with test_support.check_py3k_warnings():
            self.test_c_buffer_value(buffer)
            self.test_c_buffer_raw(buffer) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_strings.py


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