test_path.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:leetcode 作者: thomasyimgit 项目源码 文件源码
def test_not_writable_ipdir():
    tmpdir = tempfile.mkdtemp()
    os.name = "posix"
    env.pop('IPYTHON_DIR', None)
    env.pop('IPYTHONDIR', None)
    env.pop('XDG_CONFIG_HOME', None)
    env['HOME'] = tmpdir
    ipdir = os.path.join(tmpdir, '.ipython')
    os.mkdir(ipdir, 0o555)
    try:
        open(os.path.join(ipdir, "_foo_"), 'w').close()
    except IOError:
        pass
    else:
        # I can still write to an unwritable dir,
        # assume I'm root and skip the test
        raise SkipTest("I can't create directories that I can't write to")
    with AssertPrints('is not a writable location', channel='stderr'):
        ipdir = paths.get_ipython_dir()
    env.pop('IPYTHON_DIR', None)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号