Replace SafeConfigParser with ConfigParser
'SafeConfigParser' is a deprecated class. Replace the reference to it with its non-deprecated counterpart called 'ConfigParser' This change only affects how the debug.ini file is loaded, which is a file used for setting log levels within NFV. The change is not meant to affect any runtime behaviour. The intention of this code change is for this to behave the same as using SafeConfigParser. pylint was reporting this as a deprecated class (W4904) Test Plan: PASS: added a new unit test to verify coverage PASS: build ISO and unlock AIO-SX and verify vim working and startup logs appear unchanged Story: 2010531 Task: 47215 Signed-off-by: Al Bailey <al.bailey@windriver.com> Change-Id: Id0c22f9847489b171c28c11f8d8215902d444241
This commit is contained in:
parent
f05db5a028
commit
34c5178c11
@ -1,10 +1,10 @@
|
||||
#
|
||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
||||
# Copyright (c) 2015-2023 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import configparser
|
||||
import six
|
||||
from six.moves import configparser
|
||||
|
||||
from nfv_common.debug._debug_defs import DEBUG_LEVEL
|
||||
|
||||
@ -65,7 +65,7 @@ class DebugConfig(object):
|
||||
Load debug configuration
|
||||
"""
|
||||
if self._config is None:
|
||||
self._config = configparser.SafeConfigParser()
|
||||
self._config = configparser.ConfigParser()
|
||||
self._config.read(self._filename)
|
||||
|
||||
@property
|
||||
|
50
nfv/nfv-tests/nfv_unit_tests/tests/test_debug_config.py
Executable file
50
nfv/nfv-tests/nfv_unit_tests/tests/test_debug_config.py
Executable file
@ -0,0 +1,50 @@
|
||||
#
|
||||
# Copyright (c) 2023 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import os
|
||||
|
||||
from nfv_common import debug
|
||||
from nfv_common.debug._debug_defs import DEBUG_LEVEL
|
||||
from nfv_common.debug._debug_module import Debug
|
||||
|
||||
from nfv_unit_tests.tests import testcase
|
||||
|
||||
|
||||
class TestDebugConfig(testcase.NFVTestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""Setup for testing."""
|
||||
super(TestDebugConfig, self).setUp()
|
||||
|
||||
def tearDown(self):
|
||||
"""Cleanup testing setup."""
|
||||
super(TestDebugConfig, self).tearDown()
|
||||
|
||||
def test_create_debug_config(self):
|
||||
# Debug is a singleton. Its default value is VERBOSE
|
||||
self.assertEqual(Debug()._debug_level, DEBUG_LEVEL.VERBOSE)
|
||||
|
||||
# Parse a debug.ini and see if it changes
|
||||
dirname = os.path.dirname(__file__)
|
||||
debug_ini = os.path.join(dirname, '../../../nfv-vim/nfv_vim/debug.ini')
|
||||
CONF = dict()
|
||||
CONF['debug'] = dict()
|
||||
CONF['debug']['config_file'] = debug_ini
|
||||
debug.debug_initialize(CONF['debug'])
|
||||
|
||||
config = debug.debug_get_config()
|
||||
# assert that the debug CONF was populated
|
||||
self.assertEqual(CONF['debug']['config_file'], config.get('config_file'))
|
||||
|
||||
# assert that the _debug_level has changed
|
||||
self.assertNotEqual(Debug()._debug_level, DEBUG_LEVEL.VERBOSE)
|
||||
|
||||
# locally modify the debug_level
|
||||
Debug()._debug_level = DEBUG_LEVEL.VERBOSE
|
||||
self.assertEqual(Debug()._debug_level, DEBUG_LEVEL.VERBOSE)
|
||||
|
||||
# call reload_config to undo the local modification
|
||||
config = debug.debug_reload_config()
|
||||
self.assertNotEqual(Debug()._debug_level, DEBUG_LEVEL.VERBOSE)
|
@ -97,7 +97,6 @@ disable=
|
||||
W1505, # deprecated-method
|
||||
W1514, # unspecified-encoding
|
||||
W0237, # arguments-renamed
|
||||
W4904, # deprecated-class
|
||||
W4905, # deprecated-decorator
|
||||
E1101, # no-member
|
||||
E1111, # assignment-from-no-return
|
||||
|
Loading…
Reference in New Issue
Block a user