Skip to content

Commit c537cf2

Browse files
authored
Merge pull request #69 from chlowell/patch-1
Handle file not found exceptions on Python 2.7
2 parents 35641c3 + 2ec6924 commit c537cf2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

msal_extensions/token_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _reload_if_necessary(self):
3535
if self._last_sync < self._persistence.time_last_modified():
3636
self.deserialize(self._persistence.load())
3737
self._last_sync = time.time()
38-
except IOError as exp:
38+
except EnvironmentError as exp:
3939
if exp.errno != errno.ENOENT:
4040
raise
4141
# Otherwise, from cache's perspective, a nonexistent file is a NO-OP

tests/test_agnostic_backend.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,8 @@ def test_current_platform_cache_roundtrip_with_alias_class(temp_location):
4444
def test_persisted_token_cache(temp_location):
4545
_test_token_cache_roundtrip(PersistedTokenCache(FilePersistence(temp_location)))
4646

47+
def test_file_not_found_error_is_not_raised():
48+
persistence = FilePersistence('non_existing_file')
49+
cache = PersistedTokenCache(persistence=persistence)
50+
# An exception raised here will fail the test case as it is supposed to be a NO-OP
51+
cache.find('')

0 commit comments

Comments
 (0)