Replace assertRaisesRegexp with assertRaisesRegex

assertRaisesRegexp was renamed to assertRaisesRegex in Py3.2
For more details, please check:
https://docs.python.org/3/library/
unittest.html#unittest.TestCase.assertRaisesRegex

Change-Id: I705c958c0dbf1daa409ed29ccbc038426298c306
Closes-Bug: #1436957
This commit is contained in:
Vu Cong Tuan 2017-06-03 12:57:24 +07:00
parent 5a045e036d
commit cae44c7eea
2 changed files with 23 additions and 23 deletions

View File

@ -61,11 +61,11 @@ class TestConfigParsing(TestConfig):
# test a config that has multiple keys for a top-level entry
def test_config_multikey_node(self):
config = self.load_config_file('multi_key_node.yaml')
self.assertRaisesRegexp(BlockDeviceSetupException,
"Config entry top-level should be a single "
"dict:",
config_tree_to_graph,
config)
self.assertRaisesRegex(BlockDeviceSetupException,
"Config entry top-level should be a single "
"dict:",
config_tree_to_graph,
config)
# a graph should remain the same
def test_graph(self):
@ -101,19 +101,19 @@ class TestCreateGraph(TestGraphGeneration):
# Test a graph with bad edge pointing to an invalid node
def test_invalid_missing(self):
config = self.load_config_file('bad_edge_graph.yaml')
self.assertRaisesRegexp(BlockDeviceSetupException,
"Edge not defined: this_is_not_a_node",
create_graph,
config, self.fake_default_config)
self.assertRaisesRegex(BlockDeviceSetupException,
"Edge not defined: this_is_not_a_node",
create_graph,
config, self.fake_default_config)
# Test a graph with bad edge pointing to an invalid node
def test_duplicate_name(self):
config = self.load_config_file('duplicate_name.yaml')
self.assertRaisesRegexp(BlockDeviceSetupException,
"Duplicate node name: "
"this_is_a_duplicate",
create_graph,
config, self.fake_default_config)
self.assertRaisesRegex(BlockDeviceSetupException,
"Duplicate node name: "
"this_is_a_duplicate",
create_graph,
config, self.fake_default_config)
# Test digraph generation from deep_graph config file
def test_deep_graph_generator(self):

View File

@ -96,12 +96,12 @@ class TestState(TestStateBase):
# simulate the state somehow going missing, and ensure that
# later calls notice
os.unlink(state_file)
self.assertRaisesRegexp(BlockDeviceSetupException,
"State dump not found",
bd_obj.cmd_cleanup)
self.assertRaisesRegexp(BlockDeviceSetupException,
"State dump not found",
bd_obj.cmd_writefstab)
self.assertRaisesRegexp(BlockDeviceSetupException,
"State dump not found",
bd_obj.cmd_delete)
self.assertRaisesRegex(BlockDeviceSetupException,
"State dump not found",
bd_obj.cmd_cleanup)
self.assertRaisesRegex(BlockDeviceSetupException,
"State dump not found",
bd_obj.cmd_writefstab)
self.assertRaisesRegex(BlockDeviceSetupException,
"State dump not found",
bd_obj.cmd_delete)