• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python support.check_impl_detail函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_no_len_for_infinite_repeat

 def test_no_len_for_infinite_repeat(self):
     # The repeat() object can also be infinite
     if support.check_impl_detail(pypy=True):
         # 3.4 (PEP 424) behavior
         self.assertEqual(len(repeat(None)), NotImplemented)
     else:
         self.assertRaises(TypeError, len, repeat(None))
开发者ID:Qointum,项目名称:pypy,代码行数:7,代码来源:test_iterlen.py


示例2: test_invalid_sum

 def test_invalid_sum(self):
     pos = dict(lineno=2, col_offset=3)
     m = ast.Module([ast.Expr(ast.expr(**pos), **pos)])
     with self.assertRaises(TypeError) as cm:
         compile(m, "<test>", "exec")
     if support.check_impl_detail():
         self.assertIn("but got <_ast.expr", str(cm.exception))
开发者ID:timm,项目名称:timmnix,代码行数:7,代码来源:test_ast.py


示例3: test_builtin_function

 def test_builtin_function(self):
     eq = self.assertEqual
     # Functions
     eq(repr(hash), "<built-in function hash>")
     # Methods
     if check_impl_detail(pypy=False):
         self.assertTrue(repr("".split).startswith("<built-in method split of str object at 0x"))
开发者ID:Qointum,项目名称:pypy,代码行数:7,代码来源:test_reprlib.py


示例4: test_invalid_identitifer

 def test_invalid_identitifer(self):
     m = ast.Module([ast.Expr(ast.Name(42, ast.Load()))])
     ast.fix_missing_locations(m)
     with self.assertRaises(TypeError) as cm:
         compile(m, "<test>", "exec")
     if support.check_impl_detail():
         self.assertIn("identifier must be of type str", str(cm.exception))
开发者ID:timm,项目名称:timmnix,代码行数:7,代码来源:test_ast.py


示例5: test_basic_script

 def test_basic_script(self):
     with temp_dir() as script_dir:
         script_name = _make_test_script(script_dir, 'script')
         package = '' if support.check_impl_detail(pypy=True) else None
         self._check_script(script_name, script_name, script_name,
                            script_dir, package,
                            importlib.machinery.SourceFileLoader)
开发者ID:timm,项目名称:timmnix,代码行数:7,代码来源:test_cmd_line_script.py


示例6: test_one

def test_one(n):
    global mutate, dict1, dict2, dict1keys, dict2keys

    # Fill the dicts without mutating them.
    mutate = 0
    dict1keys = fill_dict(dict1, range(n), n)
    dict2keys = fill_dict(dict2, range(n), n)

    # Enable mutation, then compare the dicts so long as they have the
    # same size.
    mutate = 1
    if verbose:
        print("trying w/ lengths", len(dict1), len(dict2), end=' ')
    while dict1 and len(dict1) == len(dict2):
        if verbose:
            print(".", end=' ')
        try:
            c = dict1 == dict2
        except RuntimeError:
            # CPython never raises RuntimeError here, but other implementations
            # might, and it's fine.
            if check_impl_detail(cpython=True):
                raise
    if verbose:
        print()
开发者ID:rfk,项目名称:talk-pypyjs-what-how-why,代码行数:25,代码来源:test_mutants.py


示例7: test_invalid_string

 def test_invalid_string(self):
     m = ast.Module([ast.Expr(ast.Str(42))])
     ast.fix_missing_locations(m)
     with self.assertRaises(TypeError) as cm:
         compile(m, "<test>", "exec")
     if support.check_impl_detail():
         self.assertIn("string must be of type str or uni", str(cm.exception))
开发者ID:timm,项目名称:timmnix,代码行数:7,代码来源:test_ast.py


示例8: test_main

def test_main(verbose=None):
    from test import test_code
    run_doctest(test_code, verbose)
    tests = [CodeTest, CodeConstsTest, CodeWeakRefTest]
    if check_impl_detail(cpython=True) and ctypes is not None:
        tests.append(CoExtra)
    run_unittest(*tests)
开发者ID:1st1,项目名称:cpython,代码行数:7,代码来源:test_code.py


示例9: test_popitem

    def test_popitem(self):
        # dict.popitem()
        for copymode in -1, +1:
            # -1: b has same structure as a
            # +1: b is a.copy()
            for log2size in range(12):
                size = 2**log2size
                a = {}
                b = {}
                for i in range(size):
                    a[repr(i)] = i
                    if copymode < 0:
                        b[repr(i)] = i
                if copymode > 0:
                    b = a.copy()
                for i in range(size):
                    ka, va = ta = a.popitem()
                    self.assertEqual(va, int(ka))
                    kb, vb = tb = b.popitem()
                    self.assertEqual(vb, int(kb))
                    if support.check_impl_detail():
                        self.assertFalse(copymode < 0 and ta != tb)
                self.assertFalse(a)
                self.assertFalse(b)

        d = {}
        self.assertRaises(KeyError, d.popitem)
开发者ID:wdv4758h,项目名称:ZipPy,代码行数:27,代码来源:test_dict.py


示例10: test_c_buffer_raw

    def test_c_buffer_raw(self):
        buf = c_buffer(32)

        buf.raw = memoryview(b"Hello, World")
        self.assertEqual(buf.value, b"Hello, World")
        if support.check_impl_detail():
            self.assertRaises(TypeError, setattr, buf, "value", memoryview(b"abc"))
        self.assertRaises(ValueError, setattr, buf, "raw", memoryview(b"x" * 100))
开发者ID:timm,项目名称:timmnix,代码行数:8,代码来源:test_strings.py


示例11: test_select_mutated

 def test_select_mutated(self):
     a = []
     class F:
         def fileno(self):
             del a[-1]
             return sys.__stdout__.fileno()
     a[:] = [F()] * 10
     result = select.select([], a, [])
     # CPython: 'a' ends up with 5 items, because each fileno()
     # removes an item and at the middle the iteration stops.
     # PyPy: 'a' ends up empty, because the iteration is done on
     # a copy of the original list: fileno() is called 10 times.
     if support.check_impl_detail(cpython=True):
         self.assertEqual(len(result[1]), 5)
         self.assertEqual(len(a), 5)
     if support.check_impl_detail(pypy=True):
         self.assertEqual(len(result[1]), 10)
         self.assertEqual(len(a), 0)
开发者ID:renstrom,项目名称:gevent,代码行数:18,代码来源:test_select.py


示例12: testOpenDel

 def testOpenDel(self):
     # "Test opening and deleting a file many times"
     self.createTempFile()
     for i in range(10000):
         if support.check_impl_detail(pypy=True):
             with BZ2File(self.filename) as o:
                 pass
         else:
             o = BZ2File(self.filename)
             del o
开发者ID:wdv4758h,项目名称:ZipPy,代码行数:10,代码来源:test_bz2.py


示例13: test_script_compiled

 def test_script_compiled(self):
     with temp_dir() as script_dir:
         script_name = _make_test_script(script_dir, 'script')
         py_compile.compile(script_name, doraise=True)
         os.remove(script_name)
         pyc_file = support.make_legacy_pyc(script_name)
         package = '' if support.check_impl_detail(pypy=True) else None
         self._check_script(pyc_file, pyc_file,
                            pyc_file, script_dir, package,
                            importlib.machinery.SourcelessFileLoader)
开发者ID:timm,项目名称:timmnix,代码行数:10,代码来源:test_cmd_line_script.py


示例14: test_bad_indentation

 def test_bad_indentation(self):
     err = self.get_exception_format(self.syntax_error_bad_indentation,
                                     IndentationError)
     self.assertEqual(len(err), 4)
     self.assertEqual(err[1].strip(), "print(2)")
     if check_impl_detail():
         # on CPython, there is a "^" at the end of the line on PyPy,
         # there is a "^" too, but at the start, more logically
         self.assertIn("^", err[2])
         self.assertEqual(err[1].find(")"), err[2].find("^"))
开发者ID:Qointum,项目名称:pypy,代码行数:10,代码来源:test_traceback.py


示例15: test_issue9319

 def test_issue9319(self):
     path = os.path.dirname(__file__)
     try:
         imp.find_module("badsyntax_pep3120", [path])
     except SyntaxError:
         pass
     else:
         # PyPy's find_module won't raise a SyntaxError when checking
         # the file's magic encoding comment, the point of the test
         # is to ensure no seg fault anyway
         self.assertTrue(support.check_impl_detail(cpython=False))
开发者ID:wdv4758h,项目名称:ZipPy,代码行数:11,代码来源:test_imp.py


示例16: test_bad_integer

 def test_bad_integer(self):
     # issue13436: Bad error message with invalid numeric values
     body = [ast.ImportFrom(module='time',
                            names=[ast.alias(name='sleep')],
                            level=None,
                            lineno=None, col_offset=None)]
     mod = ast.Module(body)
     with self.assertRaises((TypeError, ValueError)) as cm:
         compile(mod, 'test', 'exec')
     if support.check_impl_detail():
         self.assertIn("invalid integer value: None", str(cm.exception))
开发者ID:timm,项目名称:timmnix,代码行数:11,代码来源:test_ast.py


示例17: test_bad_single_statement

 def test_bad_single_statement(self):
     self.assertInvalidSingle('1\n2')
     if check_impl_detail():
         # it's a single statment in PyPy
         self.assertInvalidSingle('def f(): pass')
     self.assertInvalidSingle('a = 13\nb = 187')
     self.assertInvalidSingle('del x\ndel y')
     self.assertInvalidSingle('f()\ng()')
     self.assertInvalidSingle('f()\n# blah\nblah()')
     self.assertInvalidSingle('f()\nxy # blah\nblah()')
     self.assertInvalidSingle('x = 5 # comment\nx = 6\n')
开发者ID:timm,项目名称:timmnix,代码行数:11,代码来源:test_compile.py


示例18: test_setitem_writable

    def test_setitem_writable(self):
        if not self.rw_type:
            self.skipTest("no writable type to test")
        tp = self.rw_type
        b = self.rw_type(self._source)
        oldrefcount = getrefcount(b)
        m = self._view(b)
        m[0] = ord(b'1')
        self._check_contents(tp, b, b"1bcdef")
        m[0:1] = tp(b"0")
        self._check_contents(tp, b, b"0bcdef")
        m[1:3] = tp(b"12")
        self._check_contents(tp, b, b"012def")
        m[1:1] = tp(b"")
        self._check_contents(tp, b, b"012def")
        m[:] = tp(b"abcdef")
        self._check_contents(tp, b, b"abcdef")

        # Overlapping copies of a view into itself
        m[0:3] = m[2:5]
        self._check_contents(tp, b, b"cdedef")
        m[:] = tp(b"abcdef")
        m[2:5] = m[0:3]
        self._check_contents(tp, b, b"ababcf")

        def setitem(key, value):
            m[key] = tp(value)
        # Bounds checking
        self.assertRaises(IndexError, setitem, 6, b"a")
        self.assertRaises(IndexError, setitem, -7, b"a")
        self.assertRaises(IndexError, setitem, sys.maxsize, b"a")
        self.assertRaises(IndexError, setitem, -sys.maxsize, b"a")
        # Wrong index/slice types
        self.assertRaises(TypeError, setitem, 0.0, b"a")
        if check_impl_detail():
            self.assertRaises(TypeError, setitem, (0,), b"a")
            self.assertRaises(TypeError, setitem, (slice(0,1,1), 0), b"a")
            self.assertRaises(TypeError, setitem, (0, slice(0,1,1)), b"a")
            self.assertRaises(TypeError, setitem, (0,), b"a")
        self.assertRaises(TypeError, setitem, "a", b"a")
        # Not implemented: multidimensional slices
        slices = (slice(0,1,1), slice(0,1,2))
        self.assertRaises(NotImplementedError, setitem, slices, b"a")
        # Trying to resize the memory object
        exc = ValueError if m.format == 'c' else TypeError
        self.assertRaises(exc, setitem, 0, b"")
        self.assertRaises(exc, setitem, 0, b"ab")
        self.assertRaises(ValueError, setitem, slice(1,1), b"a")
        self.assertRaises(ValueError, setitem, slice(0,2), b"a")

        m = None
        self.assertEqual(getrefcount(b), oldrefcount)
开发者ID:timm,项目名称:timmnix,代码行数:52,代码来源:test_memoryview.py


示例19: testSyntaxErrorOffset

    def testSyntaxErrorOffset(self):
        def check(src, lineno, offset):
            with self.assertRaises(SyntaxError) as cm:
                compile(src, '<fragment>', 'exec')
            self.assertEqual(cm.exception.lineno, lineno)
            self.assertEqual(cm.exception.offset, offset)

        is_pypy = check_impl_detail(pypy=True)
        check('def fact(x):\n\treturn x!\n', 2, 10)
        check('1 +\n', 1, 4 - is_pypy)
        check('def spam():\n  print(1)\n print(2)', 3, 0 if is_pypy else 10)
        check('Python = "Python" +', 1, 20 - is_pypy)
        check('Python = "\u1e54\xfd\u0163\u0125\xf2\xf1" +', 1, 20 - is_pypy)
开发者ID:timm,项目名称:timmnix,代码行数:13,代码来源:test_exceptions.py


示例20: test_AST_objects

    def test_AST_objects(self):
        if not support.check_impl_detail():
            # PyPy also provides a __dict__ to the ast.AST base class.
            return

        x = ast.AST()
        self.assertEqual(x._fields, ())

        with self.assertRaises(AttributeError):
            x.vararg

        with self.assertRaises(TypeError):
            # "_ast.AST constructor takes 0 positional arguments"
            ast.AST(2)
开发者ID:Qointum,项目名称:pypy,代码行数:14,代码来源:test_ast.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python support.check_sizeof函数代码示例发布时间:2022-05-27
下一篇:
Python support.check__all__函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap