|
23 | 23 | import unittest
|
24 | 24 | import textwrap
|
25 | 25 |
|
26 |
| - |
| 26 | +from requests.packages.urllib3.exceptions import InsecureRequestWarning |
27 | 27 | import six
|
28 | 28 |
|
29 | 29 | import swiftclient
|
@@ -1899,15 +1899,23 @@ def _test_options_passed_to_keystone(self, cmd, opts, os_opts,
|
1899 | 1899 | auth_token=token)
|
1900 | 1900 |
|
1901 | 1901 | with mock.patch('swiftclient.client._import_keystone_client',
|
1902 |
| - _make_fake_import_keystone_client(fake_ks)): |
1903 |
| - with mock.patch('swiftclient.client.http_connection', fake_conn): |
1904 |
| - with mock.patch.dict(os.environ, env, clear=True): |
1905 |
| - try: |
1906 |
| - swiftclient.shell.main(args) |
1907 |
| - except SystemExit as e: |
1908 |
| - self.fail('Unexpected SystemExit: %s' % e) |
1909 |
| - except SwiftError as err: |
1910 |
| - self.fail('Unexpected SwiftError: %s' % err) |
| 1902 | + _make_fake_import_keystone_client(fake_ks)), \ |
| 1903 | + mock.patch('swiftclient.client.http_connection', fake_conn), \ |
| 1904 | + mock.patch.dict(os.environ, env, clear=True), \ |
| 1905 | + mock.patch('requests.packages.urllib3.disable_warnings') as \ |
| 1906 | + mock_disable_warnings: |
| 1907 | + try: |
| 1908 | + swiftclient.shell.main(args) |
| 1909 | + except SystemExit as e: |
| 1910 | + self.fail('Unexpected SystemExit: %s' % e) |
| 1911 | + except SwiftError as err: |
| 1912 | + self.fail('Unexpected SwiftError: %s' % err) |
| 1913 | + |
| 1914 | + if 'insecure' in flags: |
| 1915 | + self.assertEqual([mock.call(InsecureRequestWarning)], |
| 1916 | + mock_disable_warnings.mock_calls) |
| 1917 | + else: |
| 1918 | + self.assertEqual([], mock_disable_warnings.mock_calls) |
1911 | 1919 |
|
1912 | 1920 | if no_auth:
|
1913 | 1921 | # check that keystone client was not used and terminate tests
|
|
0 commit comments