Skip to content

Commit

Permalink
Fixed downloader_test.py for python <= 2.7.8
Browse files Browse the repository at this point in the history
  • Loading branch information
captain-pool committed Jun 13, 2019
1 parent e7dfdc0 commit cebbd71
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tensorflow_datasets/core/download/downloader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def setUp(self):
'urlopen',
lambda *a, **kw: _FakeResponse(self.url, self.response, self.cookies),
).start()
if not hasattr(downloader.ssl, '_create_unverified_context'):
# To not throw error for python<=2.7.8 while mocking SSLContext functions
downloader.ssl.__dict__['_create_unverified_context'] = None
downloader.ssl.__dict__['create_default_context'] = None
absltest.mock.patch.object(
downloader.ssl,
'_create_unverified_context',
Expand Down Expand Up @@ -156,7 +160,8 @@ def test_ftp_error(self):

def test_py2_ftp_ssl_mock(self):
ssl_mock_dict = downloader.ssl.__dict__.copy()
ssl_mock_dict.pop("_create_unverified_context")
if ssl_mock_dict.get('_create_unverified_context', None):
ssl_mock_dict.pop("_create_unverified_context")
absltest.mock.patch.dict(
downloader.ssl.__dict__,
ssl_mock_dict,
Expand Down

0 comments on commit cebbd71

Please sign in to comment.