def get_cache_dir(): """Return a directory path convenient for storing user-local, package-local and version-specific cache data. """ return homebase.user_cache_dir(app_name=__packagename__, app_author=CONF_AUTHOR, version=__version__, use_virtualenv=False, create=True)
def test_user_cache_no_version_venv_no_create(self): expected = os.path.join( self.base_paths[self.platform]['user_cache_venv'], self.app_name) self.assertEqual( expected, homebase.user_cache_dir(self.app_name, app_author=self.app_author, version=None, use_virtualenv=True, create=False))
def test_user_cache_version_venv_no_create(self): version = '1.0' expected = os.path.join( self.base_paths[self.platform]['user_cache_venv'], '{}_{}'.format(self.app_name, version)) result = homebase.user_cache_dir(self.app_name, app_author=self.app_author, version=version, use_virtualenv=True, create=False) self.assertEqual(expected, result)
def test_user_cache_version_no_venv_create(self): version = "1.0" expected = os.path.join(self.base_paths[self.platform]['user_cache'], '{}_{}'.format(self.app_name, version)) if os.path.exists(expected): shutil.rmtree(expected) result = homebase.user_cache_dir(self.app_name, app_author=self.app_author, version=version, use_virtualenv=False, create=True) self.assertEqual(expected, result) self.assertTrue(os.path.exists(expected)) shutil.rmtree(expected)
def test_user_cache_no_version_venv_create(self): expected = os.path.join( self.base_paths[self.platform]['user_cache_venv'], self.app_name) if os.path.exists(expected): shutil.rmtree(expected) self.assertEqual( expected, homebase.user_cache_dir(self.app_name, app_author=self.app_author, version=None, use_virtualenv=True, create=True)) self.assertTrue(os.path.exists(expected)) shutil.rmtree(expected)
def test_user_cache_no_app_author(self): with self.assertRaises(RuntimeError): homebase.user_cache_dir(self.app_name, app_author=None)