From cae44c7eeaea90be11d4b05fcd7ecad54bf4bfe8 Mon Sep 17 00:00:00 2001 From: Vu Cong Tuan Date: Sat, 3 Jun 2017 12:57:24 +0700 Subject: [PATCH] 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 --- .../block_device/tests/test_config.py | 28 +++++++++---------- .../block_device/tests/test_state.py | 18 ++++++------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/diskimage_builder/block_device/tests/test_config.py b/diskimage_builder/block_device/tests/test_config.py index 07de0dbc..97a81728 100644 --- a/diskimage_builder/block_device/tests/test_config.py +++ b/diskimage_builder/block_device/tests/test_config.py @@ -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): diff --git a/diskimage_builder/block_device/tests/test_state.py b/diskimage_builder/block_device/tests/test_state.py index ece4a421..92a67a3d 100644 --- a/diskimage_builder/block_device/tests/test_state.py +++ b/diskimage_builder/block_device/tests/test_state.py @@ -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)