Skip to content

Commit 13ac5fd

Browse files
authored
In TestCredFunctions.is_dummy_cred treat ERROR_NOT_FOUND as empty array (mhammond#2643)
1 parent 08b122e commit 13ac5fd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

win32/test/test_win32cred.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import copy
22
import unittest
33

4+
import pywintypes
45
import win32cred
6+
import winerror
57

68

79
class TestCredFunctions(unittest.TestCase):
@@ -26,12 +28,18 @@ def create_dummy_cred(self):
2628
print(e)
2729

2830
def is_dummy_cred(self):
31+
try:
32+
credentials = win32cred.CredEnumerate()
33+
except pywintypes.error as exc:
34+
if exc.winerror != winerror.ERROR_NOT_FOUND: # Element not found.
35+
raise
36+
return False
2937
return (
3038
len(
3139
[
32-
e
33-
for e in win32cred.CredEnumerate()
34-
if e["TargetName"] == self.dummy_cred["TargetName"]
40+
True
41+
for cred in credentials
42+
if cred["TargetName"] == self.dummy_cred["TargetName"]
3543
]
3644
)
3745
== 1

0 commit comments

Comments
 (0)