Skip to content

Commit e63f5af

Browse files
Martin Larraldewillmcgugan
authored andcommitted
Fix test_entry_point_create_error (fix #185) (#186)
* Fix `test_entry_point_create_error` in `test_opener` * Use supported `setuptools` for Py3.3 in Travis-CI
1 parent 21cbbfb commit e63f5af

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

.travis.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
sudo: false
12
language: python
23

3-
python:
4-
- "2.7"
5-
- "3.3"
6-
- "3.4"
7-
- "3.5"
8-
- "3.6"
9-
10-
os:
11-
- linux
4+
matrix:
5+
include:
6+
- python: "2.7"
7+
env: SETUPTOOLS=setuptools
8+
- python: "3.3"
9+
env: SETUPTOOLS=setuptools~=39.2
10+
- python: "3.4"
11+
env: SETUPTOOLS=setuptools
12+
- python: "3.5"
13+
env: SETUPTOOLS=setuptools
14+
- python: "3.6"
15+
env: SETUPTOOLS=setuptools
1216

1317
before_install:
14-
- pip install setuptools pip -U
18+
- pip install $SETUPTOOLS pip -U
1519
- pip --version
1620
- pip install -r testrequirements.txt
1721
- pip freeze

tests/test_opener.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,19 @@ def test_entry_point_type_error(self):
216216

217217
def test_entry_point_create_error(self):
218218

219+
class BadOpener(opener.Opener):
220+
def __init__(self, *args, **kwargs):
221+
raise ValueError("some creation error")
222+
def open_fs(self, *args, **kwargs):
223+
pass
224+
219225
entry_point = mock.MagicMock()
220-
entry_point.load = mock.MagicMock(return_value=entry_point)
221-
entry_point.side_effect = ValueError("some creation error")
222-
226+
entry_point.load = mock.MagicMock(return_value=BadOpener)
223227
iter_entry_points = mock.MagicMock(return_value=iter([entry_point]))
224-
builtins = 'builtins' if six.PY3 else '__builtin__'
225228

226229
with mock.patch('pkg_resources.iter_entry_points', iter_entry_points):
227-
with mock.patch(builtins+'.issubclass', return_value=True):
228-
with self.assertRaises(errors.EntryPointError) as ctx:
229-
opener.open_fs('test://')
230+
with self.assertRaises(errors.EntryPointError) as ctx:
231+
opener.open_fs('test://')
230232
self.assertEqual(
231233
'could not instantiate opener; some creation error', str(ctx.exception))
232234

0 commit comments

Comments
 (0)