def test_empty_object(self): ''' Print object without fields. ''' class TestClass: def __init__(self): pass input_data = TestClass() expected_output = 'TestClass()' real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_empty_tuple(self): ''' Print empty tuple. ''' input_data = () expected_output = ( '<TUPLE>(\n' ')' ) real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_map_1(self): ''' Print map with one field. ''' input_data = {'field': 1} expected_output = ( '{\n' ' field: 1\n' '}' ) real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_object_with_one_field(self): ''' Print object without fields. ''' class TestClass: def __init__(self): self.field = 0 input_data = TestClass() input_data.field = 1 expected_output = 'TestClass(field=1)' real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_map_2(self): ''' Print map with two fields. ''' input_data = {'1': 1, '2': 2} expected_output = ( '{\n' ' 1: 1\n' ' 2: 2\n' '}' ) real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_simple_list(self): ''' Print simple list. ''' input_data = [1, 2, 3] expected_output = ( '[\n' ' 1,\n' ' 2,\n' ' 3,\n' ']' ) real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_simple_tuple(self): ''' Print simple tuple. ''' input_data = (1, 2, 3) expected_output = ( '<TUPLE>(\n' ' 1,\n' ' 2,\n' ' 3,\n' ')' ) real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_object_with_two_field(self): ''' Print object without fields. ''' class TestClass: def __init__(self): self.field1 = 0 self.field2 = 0 input_data = TestClass() input_data.field1 = 1 input_data.field2 = 'hi' expected_output = ( 'TestClass(\n' ' field1=1,\n' ' field2=\"hi\",\n' ')' ) real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_empty_map(self): ''' Print empty map. ''' input_data = {} expected_output = '{\n}' real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_empty_list(self): ''' Print empty list. ''' input_data = [] expected_output = '[]' real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_none(self): ''' Print None. ''' input_data = None expected_output = '<None>' real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_float(self): ''' Print floating point number. ''' input_data = 1.1 expected_output = '1.1' real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)
def test_string(self): ''' Print string. ''' input_data = 'hi' expected_output = '\"hi\"' real_output = misc.pretty_print(input_data) self.assertEqual(expected_output, real_output)