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

Python script_helper.make_pkg函数代码示例

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

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



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

示例1: test_recursion_limit

    def test_recursion_limit(self):
        subpackage = os.path.join(self.pkgdir, 'spam')
        subpackage2 = os.path.join(subpackage, 'ham')
        subpackage3 = os.path.join(subpackage2, 'eggs')
        for pkg in (subpackage, subpackage2, subpackage3):
            script_helper.make_pkg(pkg)

        subinitfn = os.path.join(subpackage, '__init__.py')
        hamfn = script_helper.make_script(subpackage, 'ham', '')
        spamfn = script_helper.make_script(subpackage2, 'spam', '')
        eggfn = script_helper.make_script(subpackage3, 'egg', '')

        self.assertRunOK('-q', '-r 0', self.pkgdir)
        self.assertNotCompiled(subinitfn)
        self.assertFalse(
            os.path.exists(os.path.join(subpackage, '__pycache__')))

        self.assertRunOK('-q', '-r 1', self.pkgdir)
        self.assertCompiled(subinitfn)
        self.assertCompiled(hamfn)
        self.assertNotCompiled(spamfn)

        self.assertRunOK('-q', '-r 2', self.pkgdir)
        self.assertCompiled(subinitfn)
        self.assertCompiled(hamfn)
        self.assertCompiled(spamfn)
        self.assertNotCompiled(eggfn)

        self.assertRunOK('-q', '-r 5', self.pkgdir)
        self.assertCompiled(subinitfn)
        self.assertCompiled(hamfn)
        self.assertCompiled(spamfn)
        self.assertCompiled(eggfn)
开发者ID:1st1,项目名称:cpython,代码行数:33,代码来源:test_compileall.py


示例2: test_package_error

 def test_package_error(self):
     with support.temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, 'test_pkg')
         make_pkg(pkg_dir)
         msg = ("'test_pkg' is a package and cannot "
                "be directly executed")
         self._check_import_error(["-m", "test_pkg"], msg, cwd=script_dir)
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:7,代码来源:test_cmd_line_script.py


示例3: test_recursion_limit

    def test_recursion_limit(self):
        subpackage = os.path.join(self.pkgdir, "spam")
        subpackage2 = os.path.join(subpackage, "ham")
        subpackage3 = os.path.join(subpackage2, "eggs")
        for pkg in (subpackage, subpackage2, subpackage3):
            script_helper.make_pkg(pkg)

        subinitfn = os.path.join(subpackage, "__init__.py")
        hamfn = script_helper.make_script(subpackage, "ham", "")
        spamfn = script_helper.make_script(subpackage2, "spam", "")
        eggfn = script_helper.make_script(subpackage3, "egg", "")

        self.assertRunOK("-q", "-r 0", self.pkgdir)
        self.assertNotCompiled(subinitfn)
        self.assertFalse(os.path.exists(os.path.join(subpackage, "__pycache__")))

        self.assertRunOK("-q", "-r 1", self.pkgdir)
        self.assertCompiled(subinitfn)
        self.assertCompiled(hamfn)
        self.assertNotCompiled(spamfn)

        self.assertRunOK("-q", "-r 2", self.pkgdir)
        self.assertCompiled(subinitfn)
        self.assertCompiled(hamfn)
        self.assertCompiled(spamfn)
        self.assertNotCompiled(eggfn)

        self.assertRunOK("-q", "-r 5", self.pkgdir)
        self.assertCompiled(subinitfn)
        self.assertCompiled(hamfn)
        self.assertCompiled(spamfn)
        self.assertCompiled(eggfn)
开发者ID:rayeya,项目名称:cpython,代码行数:32,代码来源:test_compileall.py


示例4: test_package_error

 def test_package_error(self):
     with support.temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, "test_pkg")
         make_pkg(pkg_dir)
         msg = "'test_pkg' is a package and cannot " "be directly executed"
         launch_name = _make_launch_script(script_dir, "launch", "test_pkg")
         self._check_import_error(launch_name, msg)
开发者ID:wdv4758h,项目名称:cpython,代码行数:7,代码来源:test_cmd_line_script.py


示例5: test_module_in_package

 def test_module_in_package(self):
     with support.temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, 'test_pkg')
         make_pkg(pkg_dir)
         script_name = _make_test_script(pkg_dir, 'check_sibling')
         launch_name = _make_launch_script(script_dir, 'launch',
                                           'test_pkg.check_sibling')
         self._check_script(launch_name)
开发者ID:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:8,代码来源:test_multiprocessing_main_handling.py


示例6: test_package

 def test_package(self):
     source = self.main_in_children_source
     with support.temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, 'test_pkg')
         make_pkg(pkg_dir)
         script_name = _make_test_script(pkg_dir, '__main__',
                                         source=source)
         launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
         self._check_script(launch_name)
开发者ID:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:9,代码来源:test_multiprocessing_main_handling.py


示例7: test_package

 def test_package(self):
     with support.temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, 'test_pkg')
         make_pkg(pkg_dir)
         script_name = _make_test_script(pkg_dir, '__main__')
         launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
         self._check_script(launch_name, script_name,
                            script_name, script_dir, 'test_pkg',
                            importlib.machinery.SourceFileLoader)
开发者ID:CabbageHead-360,项目名称:cpython,代码行数:9,代码来源:test_cmd_line_script.py


示例8: test_module_in_package

 def test_module_in_package(self):
     with support.temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, 'test_pkg')
         make_pkg(pkg_dir)
         script_name = _make_test_script(pkg_dir, 'script')
         self._check_script(["-m", "test_pkg.script"], script_name, script_name,
                            script_dir, 'test_pkg',
                            importlib.machinery.SourceFileLoader,
                            cwd=script_dir)
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:9,代码来源:test_cmd_line_script.py


示例9: test_module_in_package

 def test_module_in_package(self):
     with support.temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, "test_pkg")
         make_pkg(pkg_dir)
         script_name = _make_test_script(pkg_dir, "script")
         launch_name = _make_launch_script(script_dir, "launch", "test_pkg.script")
         self._check_script(
             launch_name, script_name, script_name, script_dir, "test_pkg", importlib.machinery.SourceFileLoader
         )
开发者ID:wdv4758h,项目名称:cpython,代码行数:9,代码来源:test_cmd_line_script.py


示例10: test_package_recursion

 def test_package_recursion(self):
     with support.temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, 'test_pkg')
         make_pkg(pkg_dir)
         main_dir = os.path.join(pkg_dir, '__main__')
         make_pkg(main_dir)
         msg = ("Cannot use package as __main__ module; "
                "'test_pkg' is a package and cannot "
                "be directly executed")
         self._check_import_error(["-m", "test_pkg"], msg, cwd=script_dir)
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:10,代码来源:test_cmd_line_script.py


示例11: test_package_recursion

 def test_package_recursion(self):
     with support.temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, 'test_pkg')
         make_pkg(pkg_dir)
         main_dir = os.path.join(pkg_dir, '__main__')
         make_pkg(main_dir)
         msg = ("Cannot use package as __main__ module; "
                "'test_pkg' is a package and cannot "
                "be directly executed")
         launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
         self._check_import_error(launch_name, msg)
开发者ID:CabbageHead-360,项目名称:cpython,代码行数:11,代码来源:test_cmd_line_script.py


示例12: test_package_compiled

 def test_package_compiled(self):
     source = self.main_in_children_source
     with support.temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, 'test_pkg')
         make_pkg(pkg_dir)
         script_name = _make_test_script(pkg_dir, '__main__',
                                         source=source)
         compiled_name = py_compile.compile(script_name, doraise=True)
         os.remove(script_name)
         pyc_file = support.make_legacy_pyc(script_name)
         launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
         self._check_script(launch_name)
开发者ID:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:12,代码来源:test_multiprocessing_main_handling.py


示例13: test_package_compiled

 def test_package_compiled(self):
     with support.temp_dir() as script_dir:
         pkg_dir = os.path.join(script_dir, 'test_pkg')
         make_pkg(pkg_dir)
         script_name = _make_test_script(pkg_dir, '__main__')
         compiled_name = py_compile.compile(script_name, doraise=True)
         os.remove(script_name)
         pyc_file = support.make_legacy_pyc(script_name)
         launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
         self._check_script(launch_name, pyc_file,
                            pyc_file, script_dir, 'test_pkg',
                            importlib.machinery.SourcelessFileLoader)
开发者ID:CabbageHead-360,项目名称:cpython,代码行数:12,代码来源:test_cmd_line_script.py


示例14: test_dash_m_error_code_is_one

 def test_dash_m_error_code_is_one(self):
     # If a module is invoked with the -m command line flag
     # and results in an error that the return code to the
     # shell is '1'
     with support.temp_dir() as script_dir:
         with support.change_cwd(path=script_dir):
             pkg_dir = os.path.join(script_dir, 'test_pkg')
             make_pkg(pkg_dir)
             script_name = _make_test_script(pkg_dir, 'other',
                                             "if __name__ == '__main__': raise ValueError")
             rc, out, err = assert_python_failure('-m', 'test_pkg.other', *example_args)
             if verbose > 1:
                 print(repr(out))
             self.assertEqual(rc, 1)
开发者ID:MaximVanyushkin,项目名称:Sharp.RemoteQueryable,代码行数:14,代码来源:test_cmd_line_script.py


示例15: test_issue8202

 def test_issue8202(self):
     # Make sure package __init__ modules see "-m" in sys.argv0 while
     # searching for the module to execute
     with support.temp_dir() as script_dir:
         with support.change_cwd(path=script_dir):
             pkg_dir = os.path.join(script_dir, 'test_pkg')
             make_pkg(pkg_dir, "import sys; print('init_argv0==%r' % sys.argv[0])")
             script_name = _make_test_script(pkg_dir, 'script')
             rc, out, err = assert_python_ok('-m', 'test_pkg.script', *example_args, __isolated=False)
             if verbose > 1:
                 print(repr(out))
             expected = "init_argv0==%r" % '-m'
             self.assertIn(expected.encode('utf-8'), out)
             self._check_output(script_name, rc, out,
                                script_name, script_name, '', 'test_pkg',
                                importlib.machinery.SourceFileLoader)
开发者ID:CabbageHead-360,项目名称:cpython,代码行数:16,代码来源:test_cmd_line_script.py


示例16: setup_test_pkg

 def setup_test_pkg(self, *args):
     with support.temp_dir() as script_dir, \
             support.change_cwd(path=script_dir):
         pkg_dir = os.path.join(script_dir, 'test_pkg')
         make_pkg(pkg_dir, *args)
         yield pkg_dir
开发者ID:CabbageHead-360,项目名称:cpython,代码行数:6,代码来源:test_cmd_line_script.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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