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

Python test_support.due_to_ironpython_incompatibility函数代码示例

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

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



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

示例1: test_main

def test_main():
    enabled = gc.isenabled()
    gc.disable()
    if not test_support.due_to_ironpython_incompatibility(
        "http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=314470"
    ):
        assert not gc.isenabled()
    debug = gc.get_debug()
    if not test_support.due_to_ironpython_incompatibility(
        "http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=314470"
    ):
        gc.set_debug(debug & ~gc.DEBUG_LEAK)  # this test is supposed to leak

    try:
        gc.collect()  # Delete 2nd generation garbage
        run_unittest(GCTests, GCTogglingTests)
    finally:
        if not test_support.due_to_ironpython_incompatibility(
            "http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=314470"
        ):
            gc.set_debug(debug)
        # test gc.enable() even if GC is disabled by default
        if verbose:
            print "restoring automatic collection"
        # make sure to always test gc.enable()
        gc.enable()
        assert gc.isenabled()
        if not enabled:
            gc.disable()
开发者ID:jschementi,项目名称:iron,代码行数:29,代码来源:test_gc.py


示例2: test_module_with_large_stack

    def test_module_with_large_stack(self, module='longlist'):
        # Regression test for http://bugs.python.org/issue561858.
        filename = module + os.extsep + 'py'

        # Create a file with a list of 65000 elements.
        with open(filename, 'w+') as f:
            f.write('d = [\n')
            for i in range(65000):
                f.write('"",\n')
            f.write(']')

        # Compile & remove .py file, we only need .pyc (or .pyo).
        if not due_to_ironpython_incompatibility("IronPython cannot use pyc files"):
            with open(filename, 'r') as f:
                py_compile.compile(filename)
            unlink(filename)

        # Need to be able to load from current dir.
        sys.path.append('')

        # This used to crash.
        exec 'import ' + module

        # Cleanup.
        del sys.path[-1]
        unlink(filename + 'c')
        unlink(filename + 'o')
        if due_to_ironpython_incompatibility("IronPython cannot use pyc files"):
            os.unlink(filename)
开发者ID:BillyboyD,项目名称:main,代码行数:29,代码来源:test_import.py


示例3: test_genrandbits

    def test_genrandbits(self):
        # Verify cross-platform repeatability
        self.gen.seed(1234567)
        if not test_support.due_to_ironpython_incompatibility("http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=318984"):
            self.assertEqual(self.gen.getrandbits(100),
                             97904845777343510404718956115L)
        # Verify ranges
        for k in xrange(1, 1000):
            if not test_support.due_to_ironpython_incompatibility("http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=318984"):
                self.assertTrue(0 <= self.gen.getrandbits(k) < 2**k)

        # Verify all bits active
        getbits = self.gen.getrandbits
        for span in [1, 2, 3, 4, 31, 32, 32, 52, 53, 54, 119, 127, 128, 129]:
            cum = 0
            for i in xrange(100):
                cum |= getbits(span)
            if not test_support.due_to_ironpython_incompatibility("http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=318984"):
                self.assertEqual(cum, 2**span-1)

        # Verify argument checking
        self.assertRaises(TypeError, self.gen.getrandbits)
        self.assertRaises(TypeError, self.gen.getrandbits, 'a')
        self.assertRaises(TypeError, self.gen.getrandbits, 1, 2)
        self.assertRaises(ValueError, self.gen.getrandbits, 0)
        self.assertRaises(ValueError, self.gen.getrandbits, -1)
开发者ID:BillyboyD,项目名称:main,代码行数:26,代码来源:test_random.py


示例4: test_isinstance_recursion_limit

 def test_isinstance_recursion_limit(self):
     # IronPython's recursion limit is way higher
     if test_support.due_to_ironpython_incompatibility("http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=317855"):
         reclimit = sys.getrecursionlimit()
         sys.setrecursionlimit(1000)
     # make sure that issubclass raises RuntimeError before the C stack is
     # blown
     self.assertRaises(RuntimeError, blowstack, isinstance, '', str)
     if test_support.due_to_ironpython_incompatibility("http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=317855"):
         sys.setrecursionlimit(reclimit)
开发者ID:BillyboyD,项目名称:main,代码行数:10,代码来源:test_isinstance.py


示例5: setUp

 def setUp(self):
     self.test_dir = tempfile.mkdtemp()
     sys.path.append(self.test_dir)
     self.package_dir = os.path.join(self.test_dir,
                                     self.package_name)
     os.mkdir(self.package_dir)
     if not due_to_ironpython_incompatibility("need to close file explicitly"):
         open(os.path.join(self.package_dir, '__init__'+os.extsep+'py'), 'w')
     else:
         f = open(os.path.join(self.package_dir, '__init__'+os.extsep+'py'), 'w')
     self.module_path = os.path.join(self.package_dir, 'foo'+os.extsep+'py')
     if due_to_ironpython_incompatibility("need to close file explicitly"):
         f.close()
开发者ID:BillyboyD,项目名称:main,代码行数:13,代码来源:test_pkgimport.py


示例6: test_is_tracked

    def test_is_tracked(self):
        if test_support.due_to_ironpython_incompatibility("http://ironpython.codeplex.com/workitem/17458"):
            return
        # Atomic built-in types are not tracked, user-defined objects and
        # mutable containers are.
        # NOTE: types with special optimizations (e.g. tuple) have tests
        # in their own test files instead.
        self.assertFalse(gc.is_tracked(None))
        self.assertFalse(gc.is_tracked(1))
        self.assertFalse(gc.is_tracked(1.0))
        self.assertFalse(gc.is_tracked(1.0 + 5.0j))
        self.assertFalse(gc.is_tracked(True))
        self.assertFalse(gc.is_tracked(False))
        self.assertFalse(gc.is_tracked("a"))
        self.assertFalse(gc.is_tracked(u"a"))
        self.assertFalse(gc.is_tracked(bytearray("a")))
        self.assertFalse(gc.is_tracked(type))
        self.assertFalse(gc.is_tracked(int))
        self.assertFalse(gc.is_tracked(object))
        self.assertFalse(gc.is_tracked(object()))

        class OldStyle:
            pass

        class NewStyle(object):
            pass

        self.assertTrue(gc.is_tracked(gc))
        self.assertTrue(gc.is_tracked(OldStyle))
        self.assertTrue(gc.is_tracked(OldStyle()))
        self.assertTrue(gc.is_tracked(NewStyle))
        self.assertTrue(gc.is_tracked(NewStyle()))
        self.assertTrue(gc.is_tracked([]))
        self.assertTrue(gc.is_tracked(set()))
开发者ID:jschementi,项目名称:iron,代码行数:34,代码来源:test_gc.py


示例7: test_get_referents

    def test_get_referents(self):
        if test_support.due_to_ironpython_incompatibility(
            "http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=314470"
        ):
            return
        alist = [1, 3, 5]
        got = gc.get_referents(alist)
        got.sort()
        self.assertEqual(got, alist)

        atuple = tuple(alist)
        got = gc.get_referents(atuple)
        got.sort()
        self.assertEqual(got, alist)

        adict = {1: 3, 5: 7}
        expected = [1, 3, 5, 7]
        got = gc.get_referents(adict)
        got.sort()
        self.assertEqual(got, expected)

        got = gc.get_referents([1, 2], {3: 4}, (0, 0, 0))
        got.sort()
        self.assertEqual(got, [0, 0] + range(5))

        self.assertEqual(gc.get_referents(1, "a", 4j), [])
开发者ID:jschementi,项目名称:iron,代码行数:26,代码来源:test_gc.py


示例8: test_saveall

    def test_saveall(self):
        if test_support.due_to_ironpython_incompatibility(
            "http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=314470"
        ):
            return
        # Verify that cyclic garbage like lists show up in gc.garbage if the
        # SAVEALL option is enabled.

        # First make sure we don't save away other stuff that just happens to
        # be waiting for collection.
        gc.collect()
        # if this fails, someone else created immortal trash
        self.assertEqual(gc.garbage, [])

        L = []
        L.append(L)
        id_L = id(L)

        debug = gc.get_debug()
        gc.set_debug(debug | gc.DEBUG_SAVEALL)
        del L
        gc.collect()
        gc.set_debug(debug)

        self.assertEqual(len(gc.garbage), 1)
        obj = gc.garbage.pop()
        self.assertEqual(id(obj), id_L)
开发者ID:jschementi,项目名称:iron,代码行数:27,代码来源:test_gc.py


示例9: test_chunked

    def test_chunked(self):
        chunked_start = (
            'HTTP/1.1 200 OK\r\n'
            'Transfer-Encoding: chunked\r\n\r\n'
            'a\r\n'
            'hello worl\r\n'
            '1\r\n'
            'd\r\n'
        )
        sock = FakeSocket(chunked_start + '0\r\n')
        resp = httplib.HTTPResponse(sock, method="GET")
        resp.begin()
        self.assertEquals(resp.read(), 'hello world')
        resp.close()

        for x in ('', 'foo\r\n'):
            sock = FakeSocket(chunked_start + x)
            resp = httplib.HTTPResponse(sock, method="GET")
            resp.begin()
            try:
                resp.read()
            except httplib.IncompleteRead, i:
                self.assertEquals(i.partial, 'hello world')
                if not test_support.due_to_ironpython_incompatibility("http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=21116"):
                    self.assertEqual(repr(i),'IncompleteRead(11 bytes read)')
                    self.assertEqual(str(i),'IncompleteRead(11 bytes read)')
            else:
                self.fail('IncompleteRead expected')
            finally:
开发者ID:BillyboyD,项目名称:main,代码行数:29,代码来源:test_httplib.py


示例10: test_weak_keyed_iters

    def test_weak_keyed_iters(self):
        dict, objects = self.make_weak_keyed_dict()
        self.check_iters(dict)

        # Test keyrefs()
        refs = dict.keyrefs()
        self.assertEqual(len(refs), len(objects))
        objects2 = list(objects)
        for wr in refs:
            ob = wr()
            self.assertIn(ob, dict)
            self.assertEqual(ob.arg, dict[ob])
            objects2.remove(ob)
        self.assertEqual(len(objects2), 0)

        # Test iterkeyrefs()
        objects2 = list(objects)
        self.assertEqual(len(list(dict.iterkeyrefs())), len(objects))
        for wr in dict.iterkeyrefs():
            ob = wr()
            self.assertIn(ob, dict)
            self.assertEqual(ob.arg, dict[ob])
            objects2.remove(ob)
        self.assertEqual(len(objects2), 0)

        if test_support.due_to_ironpython_incompatibility():
            keepalive(objects)
开发者ID:BillyboyD,项目名称:main,代码行数:27,代码来源:test_weakref.py


示例11: check_gc_during_creation

    def check_gc_during_creation(self, makeref):
        thresholds = gc.get_threshold()
        gc.set_threshold(1, 1, 1)
        gc.collect()
        class A:
            pass

        def callback(*args):
            pass

        referenced = A()

        a = A()
        a.a = a
        a.wr = makeref(referenced)

        try:
            # now make sure the object and the ref get labeled as
            # cyclic trash:
            a = A()
            weakref.ref(referenced, callback)
            if test_support.due_to_ironpython_incompatibility():
                keepalive(referenced)

        finally:
            gc.set_threshold(*thresholds)
开发者ID:BillyboyD,项目名称:main,代码行数:26,代码来源:test_weakref.py


示例12: 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.assertFalse(p, "proxy for empty UserList should be false")
        p.append(12)
        self.assertEqual(len(L), 1)
        self.assertTrue(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.assertIn(3, 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])
        if test_support.due_to_ironpython_incompatibility():
            keepalive(L, L2, L3)
开发者ID:BillyboyD,项目名称:main,代码行数:31,代码来源:test_weakref.py


示例13: test_bug1055820b

    def test_bug1055820b(self):
        if test_support.due_to_ironpython_incompatibility(
            "http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=314470"
        ):
            return
        # Corresponds to temp2b.py in the bug report.

        ouch = []

        def callback(ignored):
            ouch[:] = [wr() for wr in WRs]

        Cs = [C1055820(i) for i in range(2)]
        WRs = [weakref.ref(c, callback) for c in Cs]
        c = None

        gc.collect()
        self.assertEqual(len(ouch), 0)
        # Make the two instances trash, and collect again.  The bug was that
        # the callback materialized a strong reference to an instance, but gc
        # cleared the instance's dict anyway.
        Cs = None
        gc.collect()
        self.assertEqual(len(ouch), 2)  # else the callbacks didn't run
        for x in ouch:
            # If the callback resurrected one of these guys, the instance
            # would be damaged, with an empty __dict__.
            self.assertEqual(x, None)
开发者ID:jschementi,项目名称:iron,代码行数:28,代码来源:test_gc.py


示例14: test_repr

    def test_repr(self):
        l0 = []
        l2 = [0, 1, 2]
        a0 = self.type2test(l0)
        a2 = self.type2test(l2)

        self.assertEqual(str(a0), str(l0))
        self.assertEqual(repr(a0), repr(l0))
        self.assertEqual(repr(a2), repr(l2))
        self.assertEqual(str(a2), "[0, 1, 2]")
        self.assertEqual(repr(a2), "[0, 1, 2]")

        a2.append(a2)
        a2.append(3)
        self.assertEqual(str(a2), "[0, 1, 2, [...], 3]")
        self.assertEqual(repr(a2), "[0, 1, 2, [...], 3]")

        # IronPython recursion limit is way higher and results in an overflow. If
        # sys.setrecursionlimit is used to lower it, RuntimeError is still not raised below.
        if test_support.due_to_ironpython_incompatibility("http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=21116"):
            return
        l0 = []
        for i in xrange(sys.getrecursionlimit() + 100):
            l0 = [l0]
        self.assertRaises(RuntimeError, repr, l0)
开发者ID:BillyboyD,项目名称:main,代码行数:25,代码来源:list_tests.py


示例15: test_main

def test_main():
    from doctest import DocFileSuite
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(MathTests))
    if not due_to_ironpython_incompatibility("http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=21116"):
        suite.addTest(DocFileSuite("ieee754.txt"))
    run_unittest(suite)
开发者ID:BillyboyD,项目名称:main,代码行数:7,代码来源:test_math.py


示例16: test_referenceImplementation

    def test_referenceImplementation(self):
        # Compare the python implementation with results from the original
        # code.  Create 2000 53-bit precision random floats.  Compare only
        # the last ten entries to show that the independent implementations
        # are tracking.  Here is the main() function needed to create the
        # list of expected random numbers:
        #    void main(void){
        #         int i;
        #         unsigned long init[4]={61731, 24903, 614, 42143}, length=4;
        #         init_by_array(init, length);
        #         for (i=0; i<2000; i++) {
        #           printf("%.15f ", genrand_res53());
        #           if (i%5==4) printf("\n");
        #         }
        #     }
        expected = [0.45839803073713259,
                    0.86057815201978782,
                    0.92848331726782152,
                    0.35932681119782461,
                    0.081823493762449573,
                    0.14332226470169329,
                    0.084297823823520024,
                    0.53814864671831453,
                    0.089215024911993401,
                    0.78486196105372907]

        self.gen.seed(61731L + (24903L<<32) + (614L<<64) + (42143L<<96))
        actual = self.randomlist(2000)[-10:]
        for a, e in zip(actual, expected):
            if not test_support.due_to_ironpython_incompatibility("http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=318984"):
                self.assertAlmostEqual(a,e,places=14)
开发者ID:BillyboyD,项目名称:main,代码行数:31,代码来源:test_random.py


示例17: test_tuple_reuse

 def test_tuple_reuse(self):
     if test_support.due_to_ironpython_incompatibility("implementation detail: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=20279"): 
         return
     # Tests an implementation detail where tuple is reused
     # whenever nothing else holds a reference to it
     self.assertEqual(len(set(map(id, list(enumerate(self.seq))))), len(self.seq))
     self.assertEqual(len(set(map(id, enumerate(self.seq)))), min(1,len(self.seq)))
开发者ID:mcgilbertus,项目名称:main,代码行数:7,代码来源:test_enumerate.py


示例18: test_from_regex

    def test_from_regex (self):
        # Testing new regex from bug #1633678
        f = open(self._path, 'w')
        f.write("""From [email protected] Mon May 31 13:24:50 2004 +0200
Subject: message 1

body1
From [email protected] Mon May 31 13:24:50 2004 -0200
Subject: message 2

body2
From [email protected] Mon May 31 13:24:50 2004
Subject: message 3

body3
From [email protected] Mon May 31 13:24:50 2004
Subject: message 4

body4
""")
        f.close()

        if test_support.due_to_ironpython_incompatibility("http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=321793"):
            with open(self._path, 'r') as f:
                box = mailbox.UnixMailbox(f)
                self.assert_(len(list(iter(box))) == 4)
        else:
            box = mailbox.UnixMailbox(open(self._path, 'r'))
            self.assertTrue(len(list(iter(box))) == 4)
开发者ID:BillyboyD,项目名称:main,代码行数:29,代码来源:test_old_mailbox.py


示例19: test_extended_arg

    def test_extended_arg(self):
        if "debug" in sys.version.lower() and test_support.due_to_ironpython_incompatibility(
            "http://tkbgitvstfat01:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=320062"
        ):
            # this test fails on debug builds of IronPython because
            # we use too much stack space but passes on release builds
            return

        longexpr = "x = x or " + "-x" * 2500
        code = """
def f(x):
    %s
    %s
    %s
    %s
    %s
    %s
    %s
    %s
    %s
    %s
    # the expressions above have no effect, x == argument
    while x:
        x -= 1
        # EXTENDED_ARG/JUMP_ABSOLUTE here
    return x
""" % (
            (longexpr,) * 10
        )
        exec code
        self.assertEqual(f(5), 0)
开发者ID:jschementi,项目名称:iron,代码行数:31,代码来源:test_compile.py


示例20: _check_relative_imports

    def _check_relative_imports(self, depth, run_name=None):
        contents = r"""\
from __future__ import absolute_import
from . import sibling
from ..uncle.cousin import nephew
"""
        pkg_dir, mod_fname, mod_name = (
               self._make_pkg(contents, depth))
        try:
            self._add_relative_modules(pkg_dir, contents, depth)
            pkg_name = mod_name.rpartition('.')[0]
            if verbose: print "Running from source:", mod_name
            d1 = run_module(mod_name, run_name=run_name) # Read from source
            self.assertIn("__package__", d1)
            self.assertTrue(d1["__package__"] == pkg_name)
            self.assertIn("sibling", d1)
            self.assertIn("nephew", d1)
            del d1 # Ensure __loader__ entry doesn't keep file open
            __import__(mod_name)
            os.remove(mod_fname)
            if not due_to_ironpython_incompatibility("IPy can't load modules from bytecode"):
                if verbose: print "Running from compiled:", mod_name
                d2 = run_module(mod_name, run_name=run_name) # Read from bytecode
                self.assertIn("__package__", d2)
                self.assertTrue(d2["__package__"] == pkg_name)
                self.assertIn("sibling", d2)
                self.assertIn("nephew", d2)
                del d2 # Ensure __loader__ entry doesn't keep file open
        finally:
            self._del_pkg(pkg_dir, depth, mod_name)
        if verbose: print "Module executed successfully"
开发者ID:BillyboyD,项目名称:main,代码行数:31,代码来源:test_runpy.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python test_support.findfile函数代码示例发布时间:2022-05-27
下一篇:
Python test_support.due_to_ironpython_bug函数代码示例发布时间: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