Skip to content

Commit 601df71

Browse files
committed
Use glob.iglob
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent 846ca4d commit 601df71

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

bpython/autocomplete.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ def __init__(self):
163163

164164
if sys.version_info[:2] >= (3, 4):
165165
def safe_glob(self, pathname):
166-
return glob.glob(glob.escape(pathname) + '*')
166+
return glob.iglob(glob.escape(pathname) + '*')
167167
else:
168168
def safe_glob(self, pathname):
169169
try:
170-
return glob.glob(pathname + '*')
170+
return glob.iglob(pathname + '*')
171171
except re.error:
172172
# see #491
173173
return tuple()

bpython/test/test_autocomplete.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ def test_locate_fails_when_not_in_string(self):
123123
def test_locate_succeeds_when_in_string(self):
124124
self.assertEqual(self.completer.locate(4, "a'bc'd"), (2, 4, 'bc'))
125125

126-
@mock.patch('glob.glob', new=lambda text: [])
126+
@mock.patch('glob.iglob', new=lambda text: [])
127127
def test_match_returns_none_if_not_in_string(self):
128128
self.assertEqual(self.completer.matches(2, 'abcd'), None)
129129

130-
@mock.patch('glob.glob', new=lambda text: [])
130+
@mock.patch('glob.iglob', new=lambda text: [])
131131
def test_match_returns_empty_list_when_no_files(self):
132132
self.assertEqual(self.completer.matches(2, '"a'), set())
133133

134-
@mock.patch('glob.glob',
134+
@mock.patch('glob.iglob',
135135
new=lambda text: ['abcde', 'aaaaa'])
136136
@mock.patch('os.path.expanduser', new=lambda text: text)
137137
@mock.patch('os.path.isdir', new=lambda text: False)
@@ -140,7 +140,7 @@ def test_match_returns_files_when_files_exist(self):
140140
self.assertEqual(sorted(self.completer.matches(2, '"x')),
141141
['aaaaa', 'abcde'])
142142

143-
@mock.patch('glob.glob',
143+
@mock.patch('glob.iglob',
144144
new=lambda text: ['abcde', 'aaaaa'])
145145
@mock.patch('os.path.expanduser', new=lambda text: text)
146146
@mock.patch('os.path.isdir', new=lambda text: True)
@@ -149,7 +149,7 @@ def test_match_returns_dirs_when_dirs_exist(self):
149149
self.assertEqual(sorted(self.completer.matches(2, '"x')),
150150
['aaaaa/', 'abcde/'])
151151

152-
@mock.patch('glob.glob',
152+
@mock.patch('glob.iglob',
153153
new=lambda text: ['/expand/ed/abcde', '/expand/ed/aaaaa'])
154154
@mock.patch('os.path.expanduser',
155155
new=lambda text: text.replace('~', '/expand/ed'))

0 commit comments

Comments
 (0)