예제 #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")])
예제 #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"}])
예제 #3
0
 def test_whitespace(self):
     self.assertEqual(
         tabularize.loads("""
     | name | surname |
     | edi  | budu    |
     """), [{
             "name": "edi",
             "surname": "budu"
         }])
예제 #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"}])
예제 #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")])
예제 #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"}])
예제 #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"
         }])
예제 #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"
            }])
예제 #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"
            }])
예제 #10
0
 def test_ignore_headers(self):
     self.assertEqual(tabularize.loads('| name | surname |'), [])
예제 #11
0
 def test_whitespace(self):
     self.assertEqual(tabularize.loads("""
     | name | surname |
     | edi  | budu    |
     """),  [{ "name": "edi", "surname": "budu"}])
예제 #12
0
 def test_ignore_headers(self):
     self.assertEqual(tabularize.loads('| name | surname |'), [])