Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 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)
Пример #10
0
 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)
Пример #11
0
 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)
Пример #12
0
 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)
Пример #13
0
 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)