def setUp(self):
     self._datafile = TestCaseFile()
     self._datafile.directory = '/path/to'
     self._populator = FromFilePopulator(self._datafile)
     self._logger = _MockLogger()
     LOGGER.disable_message_cache()
     LOGGER.register_logger(self._logger)
示例#2
0
 def setUp(self):
     self._datafile = TestCaseFile()
     self._datafile.directory = '/path/to'
     self._populator = FromFilePopulator(self._datafile)
     self._logger = _MockLogger()
     self._console_logger = LOGGER._loggers.remove_first_regular_logger()
     LOGGER.register_logger(self._logger)
def create(data):
    tcf = TestCaseFile()
    tcf.directory = '/path/to'
    pop = FromFilePopulator(tcf)
    pop.start_table(['Test cases'])
    for row in [[cell for cell in line.split('  ')] for line in data]:
        pop.add(row)
    pop.eof()
    return tcf
示例#4
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'])
    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 \\ \\'])
    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])
 def _run(self):
     result = TestDataDirectory(source=os.path.dirname(self._path))
     result.initfile = self._path
     FromFilePopulator(result).populate(self._path)
     return result
 def _load_resource(self, path, report_status):
     r = ResourceFile(path)
     if os.stat(path)[6] != 0 and report_status:
         return r.populate()
     FromFilePopulator(r).populate(r.source)
     return r