Use ConfigParser instead of SafeConfigParser in Python 3

The SafeConfigParser class has been renamed to ConfigParser in Python
3.2 [1]. The alias SafeConfigParser maybe removed in future versions of
Python 3. Use ConfigParser instead of SafeConfigParser in Python 3

[1] http://bugs.python.org/issue10627

Change-Id: I7b550cbd7b5d4c4fe3511c456b5f738030e07d5e
Closes-Bug: #1618666
This commit is contained in:
qinchunhua 2016-09-14 02:11:48 -04:00 committed by John L. Villalovos
parent 36e7dbffe7
commit e7d88230b0
1 changed files with 6 additions and 1 deletions

View File

@ -14,6 +14,7 @@
import os
import six
import six.moves.configparser as config_parser
from tempest.lib.cli import base
from tempest.lib.common.utils import data_utils
@ -58,7 +59,11 @@ class FunctionalTestBase(base.ClientTestBase):
def _get_config(self):
config_file = os.environ.get('IRONICCLIENT_TEST_CONFIG',
DEFAULT_CONFIG_FILE)
config = config_parser.SafeConfigParser()
# SafeConfigParser was deprecated in Python 3.2
if six.PY3:
config = config_parser.ConfigParser()
else:
config = config_parser.SafeConfigParser()
if not config.read(config_file):
self.skipTest('Skipping, no test config found @ %s' % config_file)
try: