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


Python support.TestFailed方法代码示例

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


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

示例1: pickleRoundTrip

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def pickleRoundTrip(self, obj, name, dumper, loader, proto):
        save_m = sys.modules[name]
        try:
            sys.modules[name] = dumper
            temp = pickle.dumps(obj, proto)
            sys.modules[name] = loader
            result = pickle.loads(temp)
        except pickle.PicklingError as pe:
            # pyET must be second, because pyET may be (equal to) ET.
            human = dict([(ET, "cET"), (pyET, "pyET")])
            raise support.TestFailed("Failed to round-trip %r from %r to %r"
                                     % (obj,
                                        human.get(dumper, dumper),
                                        human.get(loader, loader))) from pe
        finally:
            sys.modules[name] = save_m
        return result 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:test_xml_etree.py

示例2: test_nameprep

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def test_nameprep(self):
        from encodings.idna import nameprep
        for pos, (orig, prepped) in enumerate(nameprep_tests):
            if orig is None:
                # Skipped
                continue
            # The Unicode strings are given in UTF-8
            orig = str(orig, "utf-8", "surrogatepass")
            if prepped is None:
                # Input contains prohibited characters
                self.assertRaises(UnicodeError, nameprep, orig)
            else:
                prepped = str(prepped, "utf-8", "surrogatepass")
                try:
                    self.assertEqual(nameprep(orig), prepped)
                except Exception as e:
                    raise support.TestFailed("Test 3.%d: %s" % (pos+1, str(e))) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:19,代码来源:test_codecs.py

示例3: test_exc

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def test_exc(formatstr, args, exception, excmsg):
    try:
        testformat(formatstr, args)
    except exception as exc:
        if str(exc) == excmsg:
            if verbose:
                print("yes")
        else:
            if verbose: print('no')
            print('Unexpected ', exception, ':', repr(str(exc)))
    except:
        if verbose: print('no')
        print('Unexpected exception')
        raise
    else:
        raise TestFailed('did not get expected exception: %s' % excmsg) 
开发者ID:bkerler,项目名称:android_universal,代码行数:18,代码来源:test_format.py

示例4: __cmp__

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def __cmp__(self, other):
        raise support.TestFailed("Number.__cmp__() should not be called") 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:4,代码来源:test_richcmp.py

示例5: tester

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def tester(fn, wantResult):
    fn = fn.replace("\\", "\\\\")
    gotResult = eval(fn)
    if wantResult != gotResult:
        raise TestFailed("%s should return: %s but returned: %s" \
              %(str(fn), str(wantResult), str(gotResult)))

    # then with bytes
    fn = fn.replace("('", "(b'")
    fn = fn.replace('("', '(b"')
    fn = fn.replace("['", "[b'")
    fn = fn.replace('["', '[b"')
    fn = fn.replace(", '", ", b'")
    fn = fn.replace(', "', ', b"')
    fn = os.fsencode(fn).decode('latin1')
    fn = fn.encode('ascii', 'backslashreplace').decode('ascii')
    with warnings.catch_warnings():
        warnings.simplefilter("ignore", DeprecationWarning)
        gotResult = eval(fn)
    if isinstance(wantResult, str):
        wantResult = os.fsencode(wantResult)
    elif isinstance(wantResult, tuple):
        wantResult = tuple(os.fsencode(r) for r in wantResult)

    gotResult = eval(fn)
    if wantResult != gotResult:
        raise TestFailed("%s should return: %s but returned: %s" \
              %(str(fn), str(wantResult), repr(gotResult))) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:30,代码来源:test_ntpath.py

示例6: check_ok

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def check_ok(x, x_str):
    assert x > 0.0
    x2 = eval(x_str)
    assert x2 > 0.0
    diff = abs(x - x2)
    # If diff is no larger than 3 ULP (wrt x2), then diff/8 is no larger
    # than 0.375 ULP, so adding diff/8 to x2 should have no effect.
    if x2 + (diff / 8.) != x2:
        raise TestFailed("Manifest const %s lost too much precision " % x_str) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:11,代码来源:double_const.py

示例7: test_main

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def test_main():
    from test import test_doctest2
    EXPECTED = 19
    f, t = support.run_doctest(test_doctest2)
    if t != EXPECTED:
        raise support.TestFailed("expected %d tests to run, not %d" %
                                      (EXPECTED, t))

# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested. 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:12,代码来源:test_doctest2.py

示例8: test_str_format

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def test_str_format(self):
        testformat("%r", "\u0378", "'\\u0378'")  # non printable
        testformat("%a", "\u0378", "'\\u0378'")  # non printable
        testformat("%r", "\u0374", "'\u0374'")   # printable
        testformat("%a", "\u0374", "'\\u0374'")  # printable

        # Test exception for unknown format characters, etc.
        if verbose:
            print('Testing exceptions')
        test_exc('abc %b', 1, ValueError,
                 "unsupported format character 'b' (0x62) at index 5")
        #test_exc(unicode('abc %\u3000','raw-unicode-escape'), 1, ValueError,
        #         "unsupported format character '?' (0x3000) at index 5")
        test_exc('%g', '1', TypeError, "must be real number, not str")
        test_exc('no format', '1', TypeError,
                 "not all arguments converted during string formatting")
        test_exc('%c', -1, OverflowError, "%c arg not in range(0x110000)")
        test_exc('%c', sys.maxunicode+1, OverflowError,
                 "%c arg not in range(0x110000)")
        #test_exc('%c', 2**128, OverflowError, "%c arg not in range(0x110000)")
        test_exc('%c', 3.14, TypeError, "%c requires int or char")
        test_exc('%c', 'ab', TypeError, "%c requires int or char")
        test_exc('%c', b'x', TypeError, "%c requires int or char")

        if maxsize == 2**31-1:
            # crashes 2.2.1 and earlier:
            try:
                "%*d"%(maxsize, -127)
            except MemoryError:
                pass
            else:
                raise TestFailed('"%*d"%(maxsize, -127) should fail') 
开发者ID:bkerler,项目名称:android_universal,代码行数:34,代码来源:test_format.py

示例9: runtest_inner

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def runtest_inner(test, verbose, quiet,
                  huntrleaks=False, debug=False, display_failure=True):
    support.unload(test)

    test_time = 0.0
    refleak = False  # True if the test leaked references.
    try:
        if test.startswith('test.'):
            abstest = test
        else:
            # Always import it from the test package
            abstest = 'test.' + test
        with saved_test_environment(test, verbose, quiet) as environment:
            start_time = time.time()
            the_package = __import__(abstest, globals(), locals(), [])
            the_module = getattr(the_package, test)
            # If the test has a test_main, that will run the appropriate
            # tests.  If not, use normal unittest test loading.
            test_runner = getattr(the_module, "test_main", None)
            if test_runner is None:
                tests = unittest.TestLoader().loadTestsFromModule(the_module)
                test_runner = lambda: support.run_unittest(tests)
            test_runner()
            if huntrleaks:
                refleak = dash_R(the_module, test, test_runner,
                    huntrleaks)
            test_time = time.time() - start_time
    except support.ResourceDenied as msg:
        if not quiet:
            print(test, "skipped --", msg)
            sys.stdout.flush()
        return RESOURCE_DENIED, test_time
    except unittest.SkipTest as msg:
        if not quiet:
            print(test, "skipped --", msg)
            sys.stdout.flush()
        return SKIPPED, test_time
    except KeyboardInterrupt:
        raise
    except support.TestFailed as msg:
        if display_failure:
            print("test", test, "failed --", msg, file=sys.stderr)
        else:
            print("test", test, "failed", file=sys.stderr)
        sys.stderr.flush()
        return FAILED, test_time
    except:
        msg = traceback.format_exc()
        print("test", test, "crashed --", msg, file=sys.stderr)
        sys.stderr.flush()
        return FAILED, test_time
    else:
        if refleak:
            return FAILED, test_time
        if environment.changed:
            return ENV_CHANGED, test_time
        return PASSED, test_time 
开发者ID:war-and-code,项目名称:jawfish,代码行数:59,代码来源:regrtest.py

示例10: test_str_format

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def test_str_format(self):
        testformat("%r", "\u0378", "'\\u0378'")  # non printable
        testformat("%a", "\u0378", "'\\u0378'")  # non printable
        testformat("%r", "\u0374", "'\u0374'")   # printable
        testformat("%a", "\u0374", "'\\u0374'")  # printable

        # Test exception for unknown format characters, etc.
        if verbose:
            print('Testing exceptions')
        def test_exc(formatstr, args, exception, excmsg):
            try:
                testformat(formatstr, args)
            except exception as exc:
                if str(exc) == excmsg:
                    if verbose:
                        print("yes")
                else:
                    if verbose: print('no')
                    print('Unexpected ', exception, ':', repr(str(exc)))
            except:
                if verbose: print('no')
                print('Unexpected exception')
                raise
            else:
                raise TestFailed('did not get expected exception: %s' % excmsg)
        test_exc('abc %b', 1, ValueError,
                 "unsupported format character 'b' (0x62) at index 5")
        #test_exc(unicode('abc %\u3000','raw-unicode-escape'), 1, ValueError,
        #         "unsupported format character '?' (0x3000) at index 5")
        test_exc('%d', '1', TypeError, "%d format: a number is required, not str")
        test_exc('%x', '1', TypeError, "%x format: an integer is required, not str")
        test_exc('%x', 3.14, TypeError, "%x format: an integer is required, not float")
        test_exc('%g', '1', TypeError, "a float is required")
        test_exc('no format', '1', TypeError,
                 "not all arguments converted during string formatting")
        test_exc('%c', -1, OverflowError, "%c arg not in range(0x110000)")
        test_exc('%c', sys.maxunicode+1, OverflowError,
                 "%c arg not in range(0x110000)")
        #test_exc('%c', 2**128, OverflowError, "%c arg not in range(0x110000)")
        test_exc('%c', 3.14, TypeError, "%c requires int or char")
        test_exc('%c', 'ab', TypeError, "%c requires int or char")
        test_exc('%c', b'x', TypeError, "%c requires int or char")

        if maxsize == 2**31-1:
            # crashes 2.2.1 and earlier:
            try:
                "%*d"%(maxsize, -127)
            except MemoryError:
                pass
            else:
                raise TestFailed('"%*d"%(maxsize, -127) should fail') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:53,代码来源:test_format.py

示例11: test_main

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def test_main(verbose=False):
    if support.verbose:
        import warnings
        plats = {
            'Linux': platform.linux_distribution,
            'Mac': platform.mac_ver,
            'Windows': platform.win32_ver,
        }
        with warnings.catch_warnings():
            warnings.filterwarnings(
                'ignore',
                'dist\(\) and linux_distribution\(\) '
                'functions are deprecated .*',
                PendingDeprecationWarning,
            )
            for name, func in plats.items():
                plat = func()
                if plat and plat[0]:
                    plat = '%s %r' % (name, plat)
                    break
            else:
                plat = repr(platform.platform())
        print("test_ssl: testing with %r %r" %
            (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO))
        print("          under %s" % plat)
        print("          HAS_SNI = %r" % ssl.HAS_SNI)
        print("          OP_ALL = 0x%8x" % ssl.OP_ALL)
        try:
            print("          OP_NO_TLSv1_1 = 0x%8x" % ssl.OP_NO_TLSv1_1)
        except AttributeError:
            pass

    for filename in [
        CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, BYTES_CERTFILE,
        ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY,
        SIGNED_CERTFILE, SIGNED_CERTFILE2, SIGNING_CA,
        BADCERT, BADKEY, EMPTYCERT]:
        if not os.path.exists(filename):
            raise support.TestFailed("Can't read certificate file %r" % filename)

    tests = [ContextTests, BasicSocketTests, SSLErrorTests, MemoryBIOTests]

    if support.is_resource_enabled('network'):
        tests.append(NetworkedTests)
        tests.append(NetworkedBIOTests)

    if _have_threads:
        thread_info = support.threading_setup()
        if thread_info:
            tests.append(ThreadedTests)

    try:
        support.run_unittest(*tests)
    finally:
        if _have_threads:
            support.threading_cleanup(*thread_info) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:58,代码来源:test_ssl.py

示例12: runtest_inner

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def runtest_inner(test, verbose, quiet,
                  huntrleaks=False, display_failure=True):
    support.unload(test)

    test_time = 0.0
    refleak = False  # True if the test leaked references.
    try:
        if test.startswith('test.'):
            abstest = test
        else:
            # Always import it from the test package
            abstest = 'test.' + test
        with saved_test_environment(test, verbose, quiet) as environment:
            start_time = time.time()
            the_module = importlib.import_module(abstest)
            # If the test has a test_main, that will run the appropriate
            # tests.  If not, use normal unittest test loading.
            test_runner = getattr(the_module, "test_main", None)
            if test_runner is None:
                def test_runner():
                    loader = unittest.TestLoader()
                    tests = loader.loadTestsFromModule(the_module)
                    support.run_unittest(tests)
            test_runner()
            if huntrleaks:
                refleak = dash_R(the_module, test, test_runner, huntrleaks)
            test_time = time.time() - start_time
    except support.ResourceDenied as msg:
        if not quiet:
            print(test, "skipped --", msg)
            sys.stdout.flush()
        return RESOURCE_DENIED, test_time
    except unittest.SkipTest as msg:
        if not quiet:
            print(test, "skipped --", msg)
            sys.stdout.flush()
        return SKIPPED, test_time
    except KeyboardInterrupt:
        raise
    except support.TestFailed as msg:
        if display_failure:
            print("test", test, "failed --", msg, file=sys.stderr)
        else:
            print("test", test, "failed", file=sys.stderr)
        sys.stderr.flush()
        return FAILED, test_time
    except:
        msg = traceback.format_exc()
        print("test", test, "crashed --", msg, file=sys.stderr)
        sys.stderr.flush()
        return FAILED, test_time
    else:
        if refleak:
            return FAILED, test_time
        if environment.changed:
            return ENV_CHANGED, test_time
        return PASSED, test_time 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:59,代码来源:regrtest.py

示例13: test_main

# 需要导入模块: from test import support [as 别名]
# 或者: from test.support import TestFailed [as 别名]
def test_main(verbose=False):
    if support.verbose:
        plats = {
            'Linux': platform.linux_distribution,
            'Mac': platform.mac_ver,
            'Windows': platform.win32_ver,
        }
        for name, func in plats.items():
            plat = func()
            if plat and plat[0]:
                plat = '%s %r' % (name, plat)
                break
        else:
            plat = repr(platform.platform())
        print("test_ssl: testing with %r %r" %
            (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO))
        print("          under %s" % plat)
        print("          HAS_SNI = %r" % ssl.HAS_SNI)
        print("          OP_ALL = 0x%8x" % ssl.OP_ALL)
        try:
            print("          OP_NO_TLSv1_1 = 0x%8x" % ssl.OP_NO_TLSv1_1)
        except AttributeError:
            pass

    for filename in [
        CERTFILE, REMOTE_ROOT_CERT, BYTES_CERTFILE,
        ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY,
        SIGNED_CERTFILE, SIGNED_CERTFILE2, SIGNING_CA,
        BADCERT, BADKEY, EMPTYCERT]:
        if not os.path.exists(filename):
            raise support.TestFailed("Can't read certificate file %r" % filename)

    tests = [ContextTests, BasicSocketTests, SSLErrorTests]

    if support.is_resource_enabled('network'):
        tests.append(NetworkedTests)

    if _have_threads:
        thread_info = support.threading_setup()
        if thread_info:
            tests.append(ThreadedTests)

    try:
        support.run_unittest(*tests)
    finally:
        if _have_threads:
            support.threading_cleanup(*thread_info) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:49,代码来源:test_ssl.py


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