Пример #1
0
    def test_start_table(self):
        tsv = StringIO('''*SettING*\t*  Value  *\t*V*
***Variable

*Not*Table*

Keyword*\tNot a table because doesn't start with '*'

*******************T*e*s*t*********C*a*s*e************\t***********\t******\t*
''')
        TsvReader().read(tsv, FromFilePopulator(self.tcf))
        assert_equals(self.tcf.setting_table.name, 'SettING')
        assert_equals(self.tcf.setting_table.header, ['SettING', 'Value', 'V'])
Пример #2
0
    def test_rows(self):
        tsv = StringIO('''Ignored text before tables...
Mote\tignored\text
*Setting*\t*Value*\t*Value*
Document\tWhatever\t\t\\\t
Default Tags\tt1\tt2\tt3\t\t

*Variable*\tWhatever
\\ \\ 2 escaped spaces before and after \\ \\\t\\ \\ value \\ \\

''')
        TsvReader().read(tsv, FromFilePopulator(self.tcf))
        assert_equals(self.tcf.setting_table.doc.value, 'Whatever  ')
        assert_equals(self.tcf.setting_table.default_tags.value, ['t1','t2','t3'])
        assert_equals(self.tcf.variable_table.variables[0].name, '\\ \\ 2 escaped spaces before and after \\ \\')
        assert_equals(self.tcf.variable_table.variables[0].value, ['\\ \\ value \\ \\'])
Пример #3
0
    def test_quotes(self):
        tsv = StringIO('''*Variable*\t*Value*
${v}\tHello
${v}\t"Hello"
${v}\t"""Hello"""
${v}\t"""""Hello"""""
${v}\t"Hel""lo"
${v}\t"""Hel "" """" lo"""""""
${v}\t"Hello
${v}\tHello"
''')
        TsvReader().read(tsv, FromFilePopulator(self.tcf))
        actual = [variable for variable in self.tcf.variable_table.variables]
        expected = ['Hello','Hello','"Hello"','""Hello""','Hel"lo',
                    '"Hel " "" lo"""','"Hello','Hello"']
        assert_equals(len(actual), len(expected))
        for act, exp in zip(actual, expected):
            assert_equals(act.name, '${v}')
            assert_equals(act.value, [exp])
Пример #4
0
 def test_split_row(self):
     raw_text = "col0\tcol1\tcol2"
     expected = ["col0", "col1", "col2"]
     assert_equals(TsvReader.split_row(raw_text), expected)
     assert_equals(TsvReader().split_row(raw_text), expected)
 def test_split_row(self):
     raw_text = "col0\tcol1\tcol2"
     expected = ["col0", "col1", "col2"]
     assert_equal(TsvReader.split_row(raw_text), expected)
     assert_equal(TsvReader().split_row(raw_text), expected)
Пример #6
0
 def __init__(self, varfile):
     self._variable_mapping = {}
     self._variables = []
     TsvReader().read(varfile, self)