Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def tearDown(self):
# Reset original
pypistats.CACHE_DIR = self.original_cache_dir
def test__clear_cache(self):
# Arrange
# Create old cache file
cache_file = pypistats.CACHE_DIR / "2018-11-26-old-cache-file.json"
pypistats._save_cache(cache_file, data={})
self.assertTrue(cache_file.exists())
# Act
pypistats._clear_cache()
# Assert
self.assertFalse(cache_file.exists())
def setUp(self):
# Choose a new cache dir that doesn't exist
self.original_cache_dir = pypistats.CACHE_DIR
self.temp_dir = tempfile.TemporaryDirectory()
pypistats.CACHE_DIR = Path(self.temp_dir.name) / "pypistats"
def setUp(self):
# Choose a new cache dir that doesn't exist
self.original_cache_dir = pypistats.CACHE_DIR
self.temp_dir = tempfile.TemporaryDirectory()
pypistats.CACHE_DIR = Path(self.temp_dir.name) / "pypistats"