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

Python support.temp_umask函数代码示例

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

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



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

示例1: test_unwritable_directory

 def test_unwritable_directory(self):
     # When the umask causes the new __pycache__ directory to be
     # unwritable, the import still succeeds but no .pyc file is written.
     with temp_umask(0o222):
         __import__(TESTFN)
     self.assertTrue(os.path.exists("__pycache__"))
     self.assertFalse(os.path.exists(os.path.join("__pycache__", "{}.{}.pyc".format(TESTFN, self.tag))))
开发者ID:certik,项目名称:python-3.3,代码行数:7,代码来源:test_import.py


示例2: test_unwritable_directory

 def test_unwritable_directory(self):
     # When the umask causes the new __pycache__ directory to be
     # unwritable, the import still succeeds but no .pyc file is written.
     with temp_umask(0o222):
         __import__(TESTFN)
     self.assertTrue(os.path.exists("__pycache__"))
     pyc_path = importlib.util.cache_from_source(self.source)
     self.assertFalse(os.path.exists(pyc_path), "bytecode file {!r} for {!r} " "exists".format(pyc_path, TESTFN))
开发者ID:francois-wellenreiter,项目名称:cpython,代码行数:8,代码来源:__init__.py


示例3: test_cached_readonly

    def test_cached_readonly(self):
        mode = 0o400
        with temp_umask(0o022), _ready_to_import() as (name, path):
            cached_path = importlib.util.cache_from_source(path)
            os.chmod(path, mode)
            __import__(name)
            if not os.path.exists(cached_path):
                self.fail("__import__ did not result in creation of " "a .pyc file")
            stat_info = os.stat(cached_path)

        expected = mode | 0o200  # Account for fix for issue #6074
        self.assertEqual(oct(stat.S_IMODE(stat_info.st_mode)), oct(expected))
开发者ID:francois-wellenreiter,项目名称:cpython,代码行数:12,代码来源:__init__.py


示例4: test_cached_mode_issue_2051

    def test_cached_mode_issue_2051(self):
        # permissions of .pyc should match those of .py, regardless of mask
        mode = 0o600
        with temp_umask(0o022), _ready_to_import() as (name, path):
            cached_path = importlib.util.cache_from_source(path)
            os.chmod(path, mode)
            __import__(name)
            if not os.path.exists(cached_path):
                self.fail("__import__ did not result in creation of " "a .pyc file")
            stat_info = os.stat(cached_path)

        self.assertEqual(oct(stat.S_IMODE(stat_info.st_mode)), oct(mode))
开发者ID:francois-wellenreiter,项目名称:cpython,代码行数:12,代码来源:__init__.py


示例5: test_creation_mode

    def test_creation_mode(self):
        mask = 0o022
        with temp_umask(mask), _ready_to_import() as (name, path):
            cached_path = importlib.util.cache_from_source(path)
            module = __import__(name)
            if not os.path.exists(cached_path):
                self.fail("__import__ did not result in creation of " "a .pyc file")
            stat_info = os.stat(cached_path)

        # Check that the umask is respected, and the executable bits
        # aren't set.
        self.assertEqual(oct(stat.S_IMODE(stat_info.st_mode)), oct(0o666 & ~mask))
开发者ID:francois-wellenreiter,项目名称:cpython,代码行数:12,代码来源:__init__.py


示例6: test_creation_mode

 def test_creation_mode(self):
     mask = 0o022
     with temp_umask(mask):
         sys.path.insert(0, os.curdir)
         try:
             fname = TESTFN + os.extsep + "py"
             create_empty_file(fname)
             fn = imp.cache_from_source(fname)
             unlink(fn)
             importlib.invalidate_caches()
             __import__(TESTFN)
             if not os.path.exists(fn):
                 self.fail("__import__ did not result in creation of " "either a .pyc or .pyo file")
             s = os.stat(fn)
             # Check that the umask is respected, and the executable bits
             # aren't set.
             self.assertEqual(stat.S_IMODE(s.st_mode), 0o666 & ~mask)
         finally:
             del sys.path[0]
             remove_files(TESTFN)
             unload(TESTFN)
开发者ID:certik,项目名称:python-3.3,代码行数:21,代码来源:test_import.py


示例7: test_execute_bit_not_copied

 def test_execute_bit_not_copied(self):
     # Issue 6070: under posix .pyc files got their execute bit set if
     # the .py file had the execute bit set, but they aren't executable.
     with temp_umask(0o022):
         sys.path.insert(0, os.curdir)
         try:
             fname = TESTFN + os.extsep + "py"
             open(fname, 'w').close()
             os.chmod(fname, (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
                              stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))
             fn = imp.cache_from_source(fname)
             unlink(fn)
             __import__(TESTFN)
             if not os.path.exists(fn):
                 self.fail("__import__ did not result in creation of "
                           "either a .pyc or .pyo file")
             s = os.stat(fn)
             self.assertEqual(stat.S_IMODE(s.st_mode),
                              stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
         finally:
             del sys.path[0]
             remove_files(TESTFN)
             unload(TESTFN)
开发者ID:Sherlockhlt,项目名称:pypy,代码行数:23,代码来源:test_import.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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