コード例 #1
0
ファイル: tablelib_test.py プロジェクト: cebia/stmt
    def testBasic(self):
        unformatted = """\
|_. attribute list |
|<. align left |
| cell|
|>. align right|
|=. center |
|<>. justify |
|^. valign top |
|~. bottom |
""".rstrip()

        expected = """\
|_. attribute list |
|<. align left     |
|    cell          |
|>.    align right |
|=.     center     |
|<>. justify       |
|^. valign top     |
|~. bottom         |
""".rstrip()

        formatted = tablelib.format_to_text(unformatted, self.syntax)
        self.assert_table_equals(expected, formatted)
コード例 #2
0
ファイル: tablelib_test.py プロジェクト: cebia/stmt
    def testBasic(self):
        unformatted = """\
|_. attribute list |
|<. align left |
| cell|
|>. align right|
|=. center |
|<>. justify |
|^. valign top |
|~. bottom |
""".rstrip()

        expected = """\
|_. attribute list |
|<. align left     |
|    cell          |
|>.    align right |
|=.     center     |
|<>. justify       |
|^. valign top     |
|~. bottom         |
""".rstrip()

        formatted = tablelib.format_to_text(unformatted, self.syntax)
        self.assert_table_equals(expected, formatted)
コード例 #3
0
    def test_cell_tab(self):
        raw_text = """\
|\tcol 1\t|
""".rstrip()
        expected = """\
| col 1 |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
コード例 #4
0
    def test_cell_tab(self):
        raw_text = """\
|\tcol 1\t|
""".rstrip()
        expected = """\
| col 1 |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
コード例 #5
0
    def test_auto_complete_multi_line(self):
        raw_text = """\
|
|
""".rstrip()
        expected = """\
|   |
|   |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
コード例 #6
0
    def test_auto_complete_multi_line(self):
        raw_text = """\
|
|
""".rstrip()
        expected = """\
|   |
|   |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
コード例 #7
0
    def test_prefix(self):
        raw_text = """\
    |  col 1  |  col 2  |
|---------|---------|
| cell 11 | cell 12 |
| cell 21 | cell 22 |
""".rstrip()
        expected = """\
    |  col 1  |  col 2  |
    |---------|---------|
    | cell 11 | cell 12 |
    | cell 21 | cell 22 |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
コード例 #8
0
    def test_prefix(self):
        raw_text = """\
    |  col 1  |  col 2  |
|---------|---------|
| cell 11 | cell 12 |
| cell 21 | cell 22 |
""".rstrip()
        expected = """\
    |  col 1  |  col 2  |
    |---------|---------|
    | cell 11 | cell 12 |
    | cell 21 | cell 22 |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
コード例 #9
0
    def test_auto_alignment(self):
        raw_text = """\
|column 1|column 2|
|second line 1|second line 2|
|-|-|
|text value row 1 |0.9999999999999999|
|tv row 2 |99|
""".rstrip()
        expected = """\
|     column 1     |      column 2      |
|  second line 1   |   second line 2    |
|------------------|--------------------|
| text value row 1 | 0.9999999999999999 |
| tv row 2         |                 99 |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
コード例 #10
0
    def test_auto_alignment(self):
        raw_text = """\
|column 1|column 2|
|second line 1|second line 2|
|-|-|
|text value row 1 |0.9999999999999999|
|tv row 2 |99|
""".rstrip()
        expected = """\
|     column 1     |      column 2      |
|  second line 1   |   second line 2    |
|------------------|--------------------|
| text value row 1 | 0.9999999999999999 |
| tv row 2         |                 99 |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
コード例 #11
0
    def test_specify_alignment(self):
        raw_text = """\
| column 1 | column 2 | column 3  |
| < | > | # |
|-|-|-|
| 1 | row 1 | c1 |
| 2 | row 2 | c2 |
| 3 | row 3 | c3 |
"""
        expected = """\
| column 1 | column 2 | column 3 |
| <<<<<<<< | >>>>>>>> | ######## |
|----------|----------|----------|
| 1        |    row 1 |    c1    |
| 2        |    row 2 |    c2    |
| 3        |    row 3 |    c3    |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
コード例 #12
0
    def test_specify_alignment(self):
        raw_text = """\
| column 1 | column 2 | column 3  |
| < | > | # |
|-|-|-|
| 1 | row 1 | c1 |
| 2 | row 2 | c2 |
| 3 | row 3 | c3 |
"""
        expected = """\
| column 1 | column 2 | column 3 |
| <<<<<<<< | >>>>>>>> | ######## |
|----------|----------|----------|
| 1        |    row 1 |    c1    |
| 2        |    row 2 |    c2    |
| 3        |    row 3 |    c3    |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
コード例 #13
0
ファイル: tablelib_test.py プロジェクト: cebia/stmt
    def testBasic(self):
        unformatted = """\
| Name | Gender | Age |
| Text Column | Char Column | Number Column |
|-------------|-------------|---------------|
| Alisa | F | 21 |
| Alex | M | 22 |
""".rstrip()

        expected = """\
|     Name    |    Gender   |      Age      |
| Text Column | Char Column | Number Column |
|-------------|-------------|---------------|
| Alisa       | F           |            21 |
| Alex        | M           |            22 |
""".rstrip()

        formatted = tablelib.format_to_text(unformatted, self.syntax)
        self.assert_table_equals(expected, formatted)
コード例 #14
0
ファイル: tablelib_test.py プロジェクト: cebia/stmt
    def testCustomAlignment(self):
        unformatted = """\
| Name | Gender | Age |
| > | # | < |
|---|---|---|
| Alisa | F | 21 |
| Alex | M | 22 |
""".rstrip()

        expected = """\
|  Name | Gender | Age |
| >>>>> | ###### | <<< |
|-------|--------|-----|
| Alisa |   F    | 21  |
|  Alex |   M    | 22  |
""".rstrip()

        formatted = tablelib.format_to_text(unformatted, self.syntax)
        self.assert_table_equals(expected, formatted)
コード例 #15
0
ファイル: tablelib_test.py プロジェクト: cebia/stmt
    def testBasic(self):
        unformatted = """\
| Name | Gender | Age |
| Text Column | Char Column | Number Column |
|-------------|-------------|---------------|
| Alisa | F | 21 |
| Alex | M | 22 |
""".rstrip()

        expected = """\
|     Name    |    Gender   |      Age      |
| Text Column | Char Column | Number Column |
|-------------|-------------|---------------|
| Alisa       | F           |            21 |
| Alex        | M           |            22 |
""".rstrip()

        formatted = tablelib.format_to_text(unformatted, self.syntax)
        self.assert_table_equals(expected, formatted)
コード例 #16
0
ファイル: tablelib_test.py プロジェクト: cebia/stmt
    def testCustomAlignment(self):
        unformatted = """\
| Name | Gender | Age |
| > | # | < |
|---|---|---|
| Alisa | F | 21 |
| Alex | M | 22 |
""".rstrip()

        expected = """\
|  Name | Gender | Age |
| >>>>> | ###### | <<< |
|-------|--------|-----|
| Alisa |   F    | 21  |
|  Alex |   M    | 22  |
""".rstrip()

        formatted = tablelib.format_to_text(unformatted, self.syntax)
        self.assert_table_equals(expected, formatted)
コード例 #17
0
ファイル: tablelib_test.py プロジェクト: cebia/stmt
    def testBasic(self):
        unformatted = """\
+-------------+
| widget code |
+===============================================+
| code-block::javascript                        |
|                                               |
|    widget.dispatchEvent('onSetTags', object); |
+-----------------------------------------------+
""".rstrip()

        expected = """\
+-----------------------------------------------+
|                  widget code                  |
+===============================================+
| code-block::javascript                        |
|                                               |
|    widget.dispatchEvent('onSetTags', object); |
+-----------------------------------------------+
""".rstrip()

        self.syntax.keep_space_left = True
        formatted = tablelib.format_to_text(unformatted, self.syntax)
        self.assert_table_equals(expected, formatted)
コード例 #18
0
ファイル: tablelib_test.py プロジェクト: cebia/stmt
    def testBasic(self):
        unformatted = """\
+-------------+
| widget code |
+===============================================+
| code-block::javascript                        |
|                                               |
|    widget.dispatchEvent('onSetTags', object); |
+-----------------------------------------------+
""".rstrip()

        expected = """\
+-----------------------------------------------+
|                  widget code                  |
+===============================================+
| code-block::javascript                        |
|                                               |
|    widget.dispatchEvent('onSetTags', object); |
+-----------------------------------------------+
""".rstrip()

        self.syntax.keep_space_left = True
        formatted = tablelib.format_to_text(unformatted, self.syntax)
        self.assert_table_equals(expected, formatted)
コード例 #19
0
 def test_not_table(self):
     with self.assertRaises(AssertionError):
         tablelib.format_to_text("")
コード例 #20
0
 def test_auto_complete(self):
     self.assertEquals("|   |", tablelib.format_to_text("|"))
コード例 #21
0
 def test_not_table(self):
     with self.assertRaises(AssertionError):
         tablelib.format_to_text("")
コード例 #22
0
 def test_auto_complete(self):
     self.assertEquals("|   |", tablelib.format_to_text("|"))