Beispiel #1
0
    def test_one_record(self):
        f = StringIO("PT\tAF\tC1\nJ\tAa; Bb\tX; Y")

        r = TabDelimitedReader(f)
        expected = {"PT": "J", "AF": "Aa; Bb", "C1": "X; Y"}

        assert_dict_equal(next(r), expected)
Beispiel #2
0
 def test_wos_tabdelimited_utf8(self):
     with open("data/wos_tab_delimited_win_utf8.txt",
               "rt",
               encoding="utf-8-sig") as fh:
         r = TabDelimitedReader(fh)
         for record in r:
             assert_no_bom(record)
Beispiel #3
0
    def test_multiple_records(self):
        f = StringIO("PT\tAF\tC1\nJ\tAa; Bb\tX; Y\nJ\tBb; Cc\tY; Z")
        r = TabDelimitedReader(f)

        results = [result for result in r]
        expected = [{"PT": "J", "AF": "Aa; Bb", "C1": "X; Y"},
                    {"PT": "J", "AF": "Bb; Cc", "C1": "Y; Z"}]

        assert_equal(len(results), len(expected))
        for result, exp in zip(results, expected):
            assert_dict_equal(result, exp)
Beispiel #4
0
    def test_spurious_tab_at_end(self):
        f = StringIO("PT\tAU\tC1\nJ\ta\tb\t")
        r = TabDelimitedReader(f)

        expected = {"PT": "J", "AU": "a", "C1": "b"}
        assert_dict_equal(next(r), expected)