예제 #1
0
 def test_single_new_line_block(self):
     p = para([text('1234 12 34')])
     formatter = formatter_with_page_width(5)
     actual = formatter.format_paragraph(p)
     self.assertEqual(['1234',
                       '12 34'],
                      actual)
예제 #2
0
 def test_single_new_line_block_with_alternate_page_width(self):
     p = para([text('1234 67 90')])
     formatter = formatter_with_page_width(7)
     actual = formatter.format_paragraph(p)
     self.assertEqual(['1234 67',
                       '90'],
                      actual)
예제 #3
0
 def test_too_long_line(self):
     p = para([text('1234567')])
     formatter = formatter_with_page_width(5)
     actual = formatter.format_paragraph(p)
     self.assertEqual(['12345',
                       '67'],
                      actual)
예제 #4
0
 def test_multiple_lines(self):
     # ARRANGE
     formatter = formatter_with_page_width(5)
     literal_layout = LiteralLayout('12 4567\nabcdef')
     # ACT #
     actual = formatter.format_literal_layout(literal_layout)
     # ASSERT #
     self.assertEqual(['12 45', '67', 'abcde', 'f'], actual)
예제 #5
0
 def test_single_line_that_is_longer_than_the_page_width__w_indent(self):
     # ARRANGE
     literal_layout = LiteralLayout('12 4567')
     formatter = formatter_with_page_width(6, literal_layout_indent='x')
     # ACT #
     actual = formatter.format_literal_layout(literal_layout)
     # ASSERT #
     self.assertEqual(['x12 45', 'x67'], actual)
예제 #6
0
 def test_single_line_that_is_shorter_than_the_page_width(self):
     # ARRANGE
     literal_layout = LiteralLayout('123')
     formatter = formatter_with_page_width(5)
     # ACT #
     actual = formatter.format_literal_layout(literal_layout)
     # ASSERT #
     self.assertEqual(['123'],
                      actual)
예제 #7
0
 def test_empty(self):
     # ARRANGE
     literal_layout = LiteralLayout('')
     formatter = formatter_with_page_width(5)
     # ACT #
     actual = formatter.format_literal_layout(literal_layout)
     # ASSERT #
     self.assertEqual([],
                      actual)
예제 #8
0
파일: main.py 프로젝트: emilkarlen/exactly
 def test_no_rows(self):
     # ARRANGE
     table = Table(TableFormat('|'),
                   [])
     formatter = formatter_with_page_width(5)
     # ACT #
     actual = formatter.format_table(table)
     # ASSERT #
     self.assertEqual([],
                      actual)
예제 #9
0
 def test_multiple_new_line_blocks(self):
     p = para([text('1234 12'),
               text('34 5678')])
     formatter = formatter_with_page_width(5)
     actual = formatter.format_paragraph(p)
     self.assertEqual(['1234',
                       '12',
                       '34',
                       '5678'],
                      actual)
예제 #10
0
파일: main.py 프로젝트: emilkarlen/exactly
 def test_WHEN_there_is_only_a_single_row_THEN_no_underline_should_be_rendered(self):
     # ARRANGE
     row1 = [_text_cell('row 1/cell 1')]
     table = Table(TableFormat('|', first_row_is_header=True),
                   [row1])
     formatter = formatter_with_page_width(100)
     # ACT #
     actual = formatter.format_table(table)
     # ASSERT #
     self.assertEqual(['row 1/cell 1'],
                      actual)
예제 #11
0
 def test_empty(self):
     # ARRANGE
     for indent_case in MAX_1_CHAR_INDENTS:
         with self.subTest(indent_case.name):
             formatter = formatter_with_page_width(
                 5, literal_layout_indent=indent_case.value)
             literal_layout = LiteralLayout('')
             # ACT #
             actual = formatter.format_literal_layout(literal_layout)
             # ASSERT #
             self.assertEqual([], actual)
예제 #12
0
파일: main.py 프로젝트: emilkarlen/exactly
 def test_single_cell(self):
     # ARRANGE
     row1 = [_text_cell('row 1/cell 1')]
     table = Table(TableFormat('|'),
                   [row1])
     formatter = formatter_with_page_width(100)
     # ACT #
     actual = formatter.format_table(table)
     # ASSERT #
     self.assertEqual(['row 1/cell 1'],
                      actual)
예제 #13
0
파일: main.py 프로젝트: emilkarlen/exactly
 def test_single_row_single_empty_cell(self):
     # ARRANGE
     row = [empty_cell()]
     table = Table(TableFormat('|'),
                   [row])
     formatter = formatter_with_page_width(100)
     # ACT #
     actual = formatter.format_table(table)
     # ASSERT #
     self.assertEqual([],
                      actual)
예제 #14
0
 def test_single_line_that_is_shorter_than_the_page_width(self):
     # ARRANGE
     for indent_case in MAX_1_CHAR_INDENTS:
         with self.subTest(indent_case.name):
             formatter = formatter_with_page_width(
                 5, literal_layout_indent=indent_case.value)
             literal_layout = LiteralLayout('123')
             # ACT #
             actual = formatter.format_literal_layout(literal_layout)
             # ASSERT #
             self.assertEqual(
                 _lines_starting_with(indent_case.value, ['123']), actual)
예제 #15
0
 def test_multiple_lines(self):
     # ARRANGE
     literal_layout = LiteralLayout('12 4567\nabcdef')
     formatter = formatter_with_page_width(5)
     # ACT #
     actual = formatter.format_literal_layout(literal_layout)
     # ASSERT #
     self.assertEqual(['12 45',
                       '67',
                       'abcde',
                       'f'],
                      actual)
예제 #16
0
파일: main.py 프로젝트: emilkarlen/exactly
 def test_two_row_one_emtpy_cell(self):
     # ARRANGE
     row1 = [_text_cell('row 1/col 1'), empty_cell()]
     row2 = [_text_cell('row 2/col 1'), _text_cell('row 2/col 2')]
     table = Table(TableFormat('|'),
                   [row1,
                    row2])
     formatter = formatter_with_page_width(100)
     # ACT #
     actual = formatter.format_table(table)
     # ASSERT #
     self.assertEqual(['row 1/col 1|           ',
                       'row 2/col 1|row 2/col 2'],
                      actual)
예제 #17
0
파일: main.py 프로젝트: emilkarlen/exactly
 def test_multiple_rows_multiple_columns_with_multi_character_col_separator(self):
     # ARRANGE
     row1 = [_text_cell('row 1/cell 1'), _text_cell('1/2')]
     row2 = [_text_cell('row 2/cell 1'), _text_cell('2/2')]
     table = Table(TableFormat('<<>>', first_row_is_header=True),
                   [row1,
                    row2])
     formatter = formatter_with_page_width(100)
     # ACT #
     actual = formatter.format_table(table)
     # ASSERT #
     self.assertEqual(['row 1/cell 1<<>>1/2',
                       '-------------------',
                       'row 2/cell 1<<>>2/2'],
                      actual)
예제 #18
0
파일: main.py 프로젝트: emilkarlen/exactly
 def test_multiple_rows_single_column(self):
     # ARRANGE
     row1 = [_text_cell('row 1/cell 1')]
     row2 = [_text_cell('row 2/cell 1')]
     table = Table(TableFormat('|', first_row_is_header=True),
                   [row1,
                    row2])
     formatter = formatter_with_page_width(100)
     # ACT #
     actual = formatter.format_table(table)
     # ASSERT #
     self.assertEqual(['row 1/cell 1',
                       '------------',
                       'row 2/cell 1'],
                      actual)
예제 #19
0
파일: main.py 프로젝트: emilkarlen/exactly
 def test_multiple_cells_with_different_number_of_lines(self):
     # ARRANGE
     row1 = [
         TableCell([single_text_para('row 1/cell 1 para 1'),
                    single_text_para('row 1/cell 1 para 2')]),
         TableCell([single_text_para('row 1/cell 2')]),
     ]
     table = Table(TableFormat('|'),
                   [row1])
     formatter = formatter_with_page_width(100)
     # ACT #
     actual = formatter.format_table(table)
     # ASSERT #
     expected = ['row 1/cell 1 para 1|row 1/cell 2',
                 '                   |            ',
                 'row 1/cell 1 para 2|            ']
     self.assertEqual(expected,
                      actual)