Esempio n. 1
0
    def test_different_types(self):
        self.assertEqual(tabularize.loads("""
        __________________
        | name | surname |
        | edi  | budu    |
        | budu | edi     |
        __________________
        """, return_type=list),  [["edi", "budu"], ["budu", "edi"]])

        self.assertEqual(tabularize.loads("""
        __________________
        | name | surname |
        | edi  | budu    |
        | budu | edi     |
        __________________
        """, return_type=tuple),  [("edi", "budu"), ("budu", "edi")])
Esempio n. 2
0
    def test_dashes(self):
        self.assertEqual(tabularize.loads("""
        ------------------
        | name | surname |
        ------------------
        | edi  | budu    |
        ------------------
        """),  [{ "name": "edi", "surname": "budu"}])

        self.assertEqual(tabularize.loads("""
        __________________
        | name | surname |
        ..................
        | edi  | budu    |
        __________________
        """),  [{ "name": "edi", "surname": "budu"}])
Esempio n. 3
0
 def test_whitespace(self):
     self.assertEqual(
         tabularize.loads("""
     | name | surname |
     | edi  | budu    |
     """), [{
             "name": "edi",
             "surname": "budu"
         }])
Esempio n. 4
0
 def test_multiple_lines(self):
     self.assertEqual(tabularize.loads("""
     __________________
     | name | surname |
     | edi  | budu    |
     | budu | edi     |
     __________________
     """),  [{ "name": "edi", "surname": "budu"},
             { "name": "budu", "surname": "edi"}])
Esempio n. 5
0
    def test_different_types(self):
        self.assertEqual(
            tabularize.loads("""
        __________________
        | name | surname |
        | edi  | budu    |
        | budu | edi     |
        __________________
        """,
                             return_type=list),
            [["edi", "budu"], ["budu", "edi"]])

        self.assertEqual(
            tabularize.loads("""
        __________________
        | name | surname |
        | edi  | budu    |
        | budu | edi     |
        __________________
        """,
                             return_type=tuple), [("edi", "budu"),
                                                  ("budu", "edi")])
Esempio n. 6
0
    def test_comments(self):
        self.assertEqual(tabularize.loads("""

        Here is the our customer table:

        | name  | surname  |
        | edi   | budu     |
        | budu  | edi      |

        Thanks

        """),  [{ "name": "edi", "surname": "budu"},
                { "name": "budu", "surname": "edi"}])
Esempio n. 7
0
 def test_multiple_lines(self):
     self.assertEqual(
         tabularize.loads("""
     __________________
     | name | surname |
     | edi  | budu    |
     | budu | edi     |
     __________________
     """), [{
             "name": "edi",
             "surname": "budu"
         }, {
             "name": "budu",
             "surname": "edi"
         }])
Esempio n. 8
0
    def test_dashes(self):
        self.assertEqual(
            tabularize.loads("""
        ------------------
        | name | surname |
        ------------------
        | edi  | budu    |
        ------------------
        """), [{
                "name": "edi",
                "surname": "budu"
            }])

        self.assertEqual(
            tabularize.loads("""
        __________________
        | name | surname |
        ..................
        | edi  | budu    |
        __________________
        """), [{
                "name": "edi",
                "surname": "budu"
            }])
Esempio n. 9
0
    def test_comments(self):
        self.assertEqual(
            tabularize.loads("""

        Here is the our customer table:

        | name  | surname  |
        | edi   | budu     |
        | budu  | edi      |

        Thanks

        """), [{
                "name": "edi",
                "surname": "budu"
            }, {
                "name": "budu",
                "surname": "edi"
            }])
Esempio n. 10
0
 def test_ignore_headers(self):
     self.assertEqual(tabularize.loads('| name | surname |'), [])
Esempio n. 11
0
 def test_whitespace(self):
     self.assertEqual(tabularize.loads("""
     | name | surname |
     | edi  | budu    |
     """),  [{ "name": "edi", "surname": "budu"}])
Esempio n. 12
0
 def test_ignore_headers(self):
     self.assertEqual(tabularize.loads('| name | surname |'), [])