def test_print_dict(self): cliutils.print_dict({"K": "k", "Key": "Value"}) cliutils.print_dict({"K": "k", "Key": "Long\\nValue"}) self.assertEqual(self.mock_add_row.call_args_list, [mock.call(["K", "k"]), mock.call(["Key", "Value"]), mock.call(["K", "k"]), mock.call(["Key", "Long"]), mock.call(["", "Value"])])
def test_print_dict(self): cliutils.print_dict({"K": "k", "Key": "Value"}) cliutils.print_dict({"K": "k", "Key": "Long\\nValue"}) self.mock_add_row.assert_has_calls([ mock.call(["K", "k"]), mock.call(["Key", "Value"]), mock.call(["K", "k"]), mock.call(["Key", "Long"]), mock.call(["", "Value"])], any_order=True)
def test_print_dict(self): cliutils.print_dict({"K": "k", "Key": "Value"}) cliutils.print_dict({"K": "k", "Key": "Long\\nValue"}) self.assertEqual(self.mock_add_row.call_args_list, [ mock.call(["K", "k"]), mock.call(["Key", "Value"]), mock.call(["K", "k"]), mock.call(["Key", "Long"]), mock.call(["", "Value"]) ])
def test_print_dict(self): cliutils.print_dict({"K": "k", "Key": "Value"}) cliutils.print_dict({"K": "k", "Key": "Long\\nValue"}) self.mock_add_row.assert_has_calls([ mock.call(["K", "k"]), mock.call(["Key", "Value"]), mock.call(["K", "k"]), mock.call(["Key", "Long"]), mock.call(["", "Value"]) ], any_order=True)
def test_print_dict_string(self): orig = sys.stdout sys.stdout = six.StringIO() cliutils.print_dict({"K": "k", "Key": "Value"}) out = sys.stdout.getvalue() sys.stdout.close() sys.stdout = orig expected = '''\ +----------+-------+ | Property | Value | +----------+-------+ | K | k | | Key | Value | +----------+-------+ ''' self.assertEqual(expected, out)