本文整理汇总了Python中qutebrowser.utils.standarddir._init_cachedir_tag函数的典型用法代码示例。如果您正苦于以下问题:Python _init_cachedir_tag函数的具体用法?Python _init_cachedir_tag怎么用?Python _init_cachedir_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_init_cachedir_tag函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_open_oserror
def test_open_oserror(self, caplog, tmpdir, mocker, monkeypatch):
"""Test creating a new CACHEDIR.TAG."""
monkeypatch.setattr(standarddir, 'cache', lambda: str(tmpdir))
mocker.patch('builtins.open', side_effect=OSError)
with caplog.at_level(logging.ERROR, 'init'):
standarddir._init_cachedir_tag()
assert caplog.messages == ['Failed to create CACHEDIR.TAG']
assert not tmpdir.listdir()
开发者ID:mehak,项目名称:qutebrowser,代码行数:8,代码来源:test_standarddir.py
示例2: test_open_oserror
def test_open_oserror(self, caplog, tmpdir, mocker, monkeypatch):
"""Test creating a new CACHEDIR.TAG."""
monkeypatch.setattr('qutebrowser.utils.standarddir.cache',
lambda: str(tmpdir))
mocker.patch('builtins.open', side_effect=OSError)
with caplog.at_level(logging.ERROR, 'init'):
standarddir._init_cachedir_tag()
assert len(caplog.records) == 1
assert caplog.records[0].message == 'Failed to create CACHEDIR.TAG'
assert not tmpdir.listdir()
开发者ID:Dietr1ch,项目名称:qutebrowser,代码行数:10,代码来源:test_standarddir.py
示例3: test_existent_cache_dir_tag
def test_existent_cache_dir_tag(self, tmpdir, mocker, monkeypatch):
"""Test with an existent CACHEDIR.TAG."""
monkeypatch.setattr(standarddir, 'cache', lambda: str(tmpdir))
mocker.patch('builtins.open', side_effect=AssertionError)
m = mocker.patch('qutebrowser.utils.standarddir.os')
m.path.join.side_effect = os.path.join
m.path.exists.return_value = True
standarddir._init_cachedir_tag()
assert not tmpdir.listdir()
m.path.exists.assert_called_with(str(tmpdir / 'CACHEDIR.TAG'))
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:10,代码来源:test_standarddir.py
示例4: test_new_cache_dir_tag
def test_new_cache_dir_tag(self, tmpdir, mocker, monkeypatch):
"""Test creating a new CACHEDIR.TAG."""
monkeypatch.setattr(standarddir, 'cache', lambda: str(tmpdir))
standarddir._init_cachedir_tag()
assert tmpdir.listdir() == [(tmpdir / 'CACHEDIR.TAG')]
data = (tmpdir / 'CACHEDIR.TAG').read_text('utf-8')
assert data == textwrap.dedent("""
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by qutebrowser.
# For information about cache directory tags, see:
# http://www.brynosaurus.com/cachedir/
""").lstrip()
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:12,代码来源:test_standarddir.py
示例5: test_no_cache_dir
def test_no_cache_dir(self, mocker, monkeypatch):
"""Smoke test with cache() returning None."""
monkeypatch.setattr('qutebrowser.utils.standarddir.cache',
lambda: None)
mocker.patch('builtins.open', side_effect=AssertionError)
standarddir._init_cachedir_tag()
开发者ID:Dietr1ch,项目名称:qutebrowser,代码行数:6,代码来源:test_standarddir.py
注:本文中的qutebrowser.utils.standarddir._init_cachedir_tag函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论