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


Python script_helper.assert_python_failure方法代码示例

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


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

示例1: test_daemon_threads_fatal_error

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def test_daemon_threads_fatal_error(self):
        subinterp_code = r"""if 1:
            import os
            import threading
            import time

            def f():
                # Make sure the daemon thread is still running when
                # Py_EndInterpreter is called.
                time.sleep(10)
            threading.Thread(target=f, daemon=True).start()
            """
        script = r"""if 1:
            import _testcapi

            _testcapi.run_in_subinterp(%r)
            """ % (subinterp_code,)
        with test.support.SuppressCrashReport():
            rc, out, err = assert_python_failure("-c", script)
        self.assertIn("Fatal Python error: Py_EndInterpreter: "
                      "not the last thread", err.decode()) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:23,代码来源:test_threading.py

示例2: zipfilecmd_failure

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def zipfilecmd_failure(self, *args):
        return script_helper.assert_python_failure('-m', 'zipfile', *args) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:test_zipfile.py

示例3: assertFailure

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def assertFailure(self, *args):
        rc, stdout, stderr = assert_python_failure('-m', 'calendar', *args)
        self.assertIn(b'Usage:', stderr)
        self.assertEqual(rc, 2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_calendar.py

示例4: test_trigger_memory_error

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def test_trigger_memory_error(self):
        e = self._nested_expression(100)
        rc, out, err = assert_python_failure('-c', e)
        # parsing the expression will result in an error message
        # followed by a MemoryError (see #11963)
        self.assertIn(b's_push: parser stack overflow', err)
        self.assertIn(b'MemoryError', err) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_parser.py

示例5: test_yet_more_evil_still_undecodable

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def test_yet_more_evil_still_undecodable(self):
        # Issue #25388
        src = b"#\x00\n#\xfd\n"
        tmpd = tempfile.mkdtemp()
        try:
            fn = os.path.join(tmpd, "bad.py")
            with open(fn, "wb") as fp:
                fp.write(src)
            rc, out, err = script_helper.assert_python_failure(fn)
        finally:
            test_support.rmtree(tmpd)
        self.assertIn(b"Non-ASCII", err) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_compile.py

示例6: test_finalize_runnning_thread

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def test_finalize_runnning_thread(self):
        # Issue 1402: the PyGILState_Ensure / _Release functions may be called
        # very late on python exit: on deallocation of a running thread for
        # example.
        import_module("ctypes")

        rc, out, err = assert_python_failure("-c", """if 1:
            import ctypes, sys, time, _thread

            # This lock is used as a simple event variable.
            ready = _thread.allocate_lock()
            ready.acquire()

            # Module globals are cleared before __del__ is run
            # So we save the functions in class dict
            class C:
                ensure = ctypes.pythonapi.PyGILState_Ensure
                release = ctypes.pythonapi.PyGILState_Release
                def __del__(self):
                    state = self.ensure()
                    self.release(state)

            def waitingThread():
                x = C()
                ready.release()
                time.sleep(100)

            _thread.start_new_thread(waitingThread, ())
            ready.acquire()  # Be sure the other thread is waiting.
            sys.exit(42)
            """)
        self.assertEqual(rc, 42) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:34,代码来源:test_threading.py

示例7: test_assert_python_failure

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def test_assert_python_failure(self):
        # I didn't import the sys module so this child will fail.
        rc, out, err = script_helper.assert_python_failure('-c', 'sys.exit(0)')
        self.assertNotEqual(0, rc, 'return code should not be 0') 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:6,代码来源:test_script_helper.py

示例8: test_assert_python_failure_raises

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def test_assert_python_failure_raises(self):
        with self.assertRaises(AssertionError) as error_context:
            script_helper.assert_python_failure('-c', 'import sys; sys.exit(0)')
        error_msg = str(error_context.exception)
        self.assertIn('Process return code is 0,', error_msg)
        self.assertIn('import sys; sys.exit(0)', error_msg,
                      msg='unexpected command line.') 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:9,代码来源:test_script_helper.py

示例9: test_env_var_invalid

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def test_env_var_invalid(self):
        for nframe in (-1, 0, 2**30):
            with self.subTest(nframe=nframe):
                with support.SuppressCrashReport():
                    ok, stdout, stderr = assert_python_failure(
                        '-c', 'pass',
                        PYTHONTRACEMALLOC=str(nframe))
                    self.assertIn(b'PYTHONTRACEMALLOC: invalid '
                                  b'number of frames',
                                  stderr) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:12,代码来源:test_tracemalloc.py

示例10: test_usage

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def test_usage(self):
        rc, out, err = assert_python_failure(self.script, '-h')
        self.assertEqual(rc, 2)
        self.assertEqual(out, b'')
        self.assertGreater(err, b'') 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:7,代码来源:test_md5sum.py

示例11: tarfilecmd_failure

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def tarfilecmd_failure(self, *args):
        return script_helper.assert_python_failure('-m', 'tarfile', *args) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:4,代码来源:test_tarfile.py

示例12: assertRunNotOK

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def assertRunNotOK(self, *args, **env_vars):
        rc, out, err = script_helper.assert_python_failure(
                        *self._get_run_args(args), **env_vars)
        return rc, out, err 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:6,代码来源:test_compileall.py

示例13: test_d_runtime_error

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def test_d_runtime_error(self):
        bazfn = script_helper.make_script(self.pkgdir, 'baz', 'raise Exception')
        self.assertRunOK('-q', '-d', 'dinsdale', self.pkgdir)
        fn = script_helper.make_script(self.pkgdir, 'bing', 'import baz')
        pyc = importlib.util.cache_from_source(bazfn)
        os.rename(pyc, os.path.join(self.pkgdir, 'baz.pyc'))
        os.remove(bazfn)
        rc, out, err = script_helper.assert_python_failure(fn, __isolated=False)
        self.assertRegex(err, b'File "dinsdale') 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:11,代码来源:test_compileall.py

示例14: test_builtins

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def test_builtins(self):
        module = importlib.import_module('unittest')
        _, out, err = assert_python_failure('-m', 'inspect',
                                            'sys')
        lines = err.decode().splitlines()
        self.assertEqual(lines, ["Can't get info for builtin modules."]) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:8,代码来源:test_inspect.py

示例15: test_syshook_no_logdir_default_format

# 需要导入模块: from test import script_helper [as 别名]
# 或者: from test.script_helper import assert_python_failure [as 别名]
def test_syshook_no_logdir_default_format(self):
        with temp_dir() as tracedir:
            rc, out, err = assert_python_failure(
                  '-c',
                  ('import cgitb; cgitb.enable(logdir=%s); '
                   'raise ValueError("Hello World")') % repr(tracedir))
        out = out.decode(sys.getfilesystemencoding())
        self.assertIn("ValueError", out)
        self.assertIn("Hello World", out)
        # By default we emit HTML markup.
        self.assertIn('<p>', out)
        self.assertIn('</p>', out) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:14,代码来源:test_cgitb.py


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