Skip to content

Commit 45fb40d

Browse files
committed
Patch correct function
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent 77506c1 commit 45fb40d

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

bpython/test/test_autocomplete.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from collections import namedtuple
44
import inspect
55
import keyword
6-
from bpython._py3compat import py3
6+
import sys
77

88
try:
99
import unittest2 as unittest
@@ -17,8 +17,14 @@
1717
has_jedi = False
1818

1919
from bpython import autocomplete
20+
from bpython._py3compat import py3
2021
from bpython.test import mock
2122

23+
if sys.version_info[:2] >= (3, 4):
24+
glob_function = 'glob.iglob'
25+
else:
26+
glob_function = 'glob.glob'
27+
2228

2329
class TestSafeEval(unittest.TestCase):
2430
def test_catches_syntax_error(self):
@@ -123,33 +129,31 @@ def test_locate_fails_when_not_in_string(self):
123129
def test_locate_succeeds_when_in_string(self):
124130
self.assertEqual(self.completer.locate(4, "a'bc'd"), (2, 4, 'bc'))
125131

126-
@mock.patch('glob.iglob', new=lambda text: [])
132+
@mock.patch(glob_function, new=lambda text: [])
127133
def test_match_returns_none_if_not_in_string(self):
128134
self.assertEqual(self.completer.matches(2, 'abcd'), None)
129135

130-
@mock.patch('glob.iglob', new=lambda text: [])
136+
@mock.patch(glob_function, new=lambda text: [])
131137
def test_match_returns_empty_list_when_no_files(self):
132138
self.assertEqual(self.completer.matches(2, '"a'), set())
133139

134-
@mock.patch('glob.iglob',
135-
new=lambda text: ['abcde', 'aaaaa'])
140+
@mock.patch(glob_function, new=lambda text: ['abcde', 'aaaaa'])
136141
@mock.patch('os.path.expanduser', new=lambda text: text)
137142
@mock.patch('os.path.isdir', new=lambda text: False)
138143
@mock.patch('os.path.sep', new='/')
139144
def test_match_returns_files_when_files_exist(self):
140145
self.assertEqual(sorted(self.completer.matches(2, '"x')),
141146
['aaaaa', 'abcde'])
142147

143-
@mock.patch('glob.iglob',
144-
new=lambda text: ['abcde', 'aaaaa'])
148+
@mock.patch(glob_function, new=lambda text: ['abcde', 'aaaaa'])
145149
@mock.patch('os.path.expanduser', new=lambda text: text)
146150
@mock.patch('os.path.isdir', new=lambda text: True)
147151
@mock.patch('os.path.sep', new='/')
148152
def test_match_returns_dirs_when_dirs_exist(self):
149153
self.assertEqual(sorted(self.completer.matches(2, '"x')),
150154
['aaaaa/', 'abcde/'])
151155

152-
@mock.patch('glob.iglob',
156+
@mock.patch(glob_function,
153157
new=lambda text: ['/expand/ed/abcde', '/expand/ed/aaaaa'])
154158
@mock.patch('os.path.expanduser',
155159
new=lambda text: text.replace('~', '/expand/ed'))

0 commit comments

Comments
 (0)