Beispiel #1
0
    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)
Beispiel #2
0
    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)
    def test_cell_tab(self):
        raw_text = """\
|\tcol 1\t|
""".rstrip()
        expected = """\
| col 1 |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
    def test_cell_tab(self):
        raw_text = """\
|\tcol 1\t|
""".rstrip()
        expected = """\
| col 1 |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
    def test_auto_complete_multi_line(self):
        raw_text = """\
|
|
""".rstrip()
        expected = """\
|   |
|   |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
    def test_auto_complete_multi_line(self):
        raw_text = """\
|
|
""".rstrip()
        expected = """\
|   |
|   |
""".rstrip()
        self.assertMultiLineEqual(expected, tablelib.format_to_text(raw_text))
    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))
    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))
    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))
    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))
    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))
    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))
Beispiel #13
0
    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)
Beispiel #14
0
    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)
Beispiel #15
0
    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)
Beispiel #16
0
    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)
Beispiel #17
0
    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)
Beispiel #18
0
    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)
 def test_not_table(self):
     with self.assertRaises(AssertionError):
         tablelib.format_to_text("")
 def test_auto_complete(self):
     self.assertEquals("|   |", tablelib.format_to_text("|"))
 def test_not_table(self):
     with self.assertRaises(AssertionError):
         tablelib.format_to_text("")
 def test_auto_complete(self):
     self.assertEquals("|   |", tablelib.format_to_text("|"))