本文整理匯總了Python中ulif.openoffice.cachemanager.CacheManager._prepare_cache_dir方法的典型用法代碼示例。如果您正苦於以下問題:Python CacheManager._prepare_cache_dir方法的具體用法?Python CacheManager._prepare_cache_dir怎麽用?Python CacheManager._prepare_cache_dir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ulif.openoffice.cachemanager.CacheManager
的用法示例。
在下文中一共展示了CacheManager._prepare_cache_dir方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_prepare_cache_dir_broken
# 需要導入模塊: from ulif.openoffice.cachemanager import CacheManager [as 別名]
# 或者: from ulif.openoffice.cachemanager.CacheManager import _prepare_cache_dir [as 別名]
def test_prepare_cache_dir_broken(self, tmpdir):
# we fail loudly if we cannot create a cache dir
cm = CacheManager(str(tmpdir))
tmpdir.join("not-a-dir.txt").write("foo") # broken dir
cm.cache_dir = str(tmpdir / "not-a-dir.txt")
with pytest.raises(IOError):
cm._prepare_cache_dir()
示例2: test_prepare_cache_dir
# 需要導入模塊: from ulif.openoffice.cachemanager import CacheManager [as 別名]
# 或者: from ulif.openoffice.cachemanager.CacheManager import _prepare_cache_dir [as 別名]
def test_prepare_cache_dir(self, tmpdir):
# _prepare_cache_dir creates a cache dir normally
cm = CacheManager(str(tmpdir.join("cache")))
new_dir = tmpdir.join("new_dir")
cm.cache_dir = str(new_dir)
cm._prepare_cache_dir()
assert new_dir.isdir() is True
示例3: test_prepare_cache_dir
# 需要導入模塊: from ulif.openoffice.cachemanager import CacheManager [as 別名]
# 或者: from ulif.openoffice.cachemanager.CacheManager import _prepare_cache_dir [as 別名]
def test_prepare_cache_dir(self):
new_cache_dir = os.path.join(self.workdir, 'newcache')
broken_cache_dir = os.path.join(self.workdir, 'broken')
open(broken_cache_dir, 'w').write('broken')
cm = CacheManager(self.workdir)
cm.cache_dir = None
self.assertEqual(cm._prepare_cache_dir(), None)
cm.cache_dir = new_cache_dir
cm._prepare_cache_dir()
self.assertTrue(os.path.isdir(new_cache_dir))
cm.cache_dir = broken_cache_dir
self.assertRaises(IOError, cm._prepare_cache_dir)
return
示例4: test_prepare_cache_dir_none
# 需要導入模塊: from ulif.openoffice.cachemanager import CacheManager [as 別名]
# 或者: from ulif.openoffice.cachemanager.CacheManager import _prepare_cache_dir [as 別名]
def test_prepare_cache_dir_none(self, tmpdir):
# we can create a cache manager without any cache dir
cm = CacheManager(str(tmpdir))
cm.cache_dir = None
cm._prepare_cache_dir()
assert cm.cache_dir is None