Example # Comment Keyword arg ...\targh \t\t *** Keywords *** # Comment continues Keyword [Arguments] ${arg1} ${arg2} Log Got ${arg1} and ${arg}! ''' PATH = os.path.join( os.getenv('TEMPDIR') or tempfile.gettempdir(), 'test_model.robot') EXPECTED = File(sections=[ CommentSection(body=[EmptyLine([Token('EOL', '\n', 1, 0)])]), TestCaseSection(header=TestCaseSectionHeader([ Token('TESTCASE_HEADER', '*** Test Cases ***', 2, 0), Token('EOL', '\n', 2, 18) ]), body=[ EmptyLine([Token('EOL', '\n', 3, 0)]), TestCase(header=TestCaseName([ Token('TESTCASE_NAME', 'Example', 4, 0), Token('EOL', '\n', 4, 7) ]), body=[ Comment([ Token('SEPARATOR', ' ', 5, 0), Token('COMMENT', '# Comment', 5, 2), Token('EOL', '\n', 5, 11),
...\targh \t\t *** Keywords *** # Comment continues Keyword [Arguments] ${arg1} ${arg2} Log Got ${arg1} and ${arg}! ''' PATH = os.path.join(os.getenv('TEMPDIR') or tempfile.gettempdir(), 'test_model.robot') EXPECTED = File(sections=[ CommentSection( body=[ EmptyLine([ Token('EOL', '\n', 1, 0) ]) ] ), TestCaseSection( header=SectionHeader([ Token('TESTCASE HEADER', '*** Test Cases ***', 2, 0), Token('EOL', '\n', 2, 18) ]), body=[ EmptyLine([Token('EOL', '\n', 3, 0)]), TestCase( header=TestCaseName([ Token('TESTCASE NAME', 'Example', 4, 0), Token('EOL', '\n', 4, 7) ]),
def visit_Section(self, node): if node != self.sections[-1]: node.body.add(EmptyLine([Token(Token.EOL, self._newline)])) self.generic_visit(node) return node
def visit_Keyword(self, node): if not node.body.items or node != self.keywords[-1]: node.body.items.append(EmptyLine([Token(Token.EOL, self._newline)])) self.generic_visit(node) return node
DATA = ''' *** Test Cases *** Example Keyword arg ... argh *** Keywords *** Keyword [Arguments] ${arg1} ${arg2} Log Got ${arg1} and ${arg}! ''' PATH = os.path.join( os.getenv('TEMPDIR') or tempfile.gettempdir(), 'test_model.robot') EXPECTED = File(sections=[ CommentSection(body=[EmptyLine([Token('EOL', '\n', 1, 0)])]), TestCaseSection(header=TestCaseSectionHeader([ Token('TESTCASE_HEADER', '*** Test Cases ***', 2, 0), Token('EOL', '\n', 2, 18) ]), body=[ TestCase(header=TestCaseName([ Token('TESTCASE_NAME', 'Example', 3, 0), Token('EOL', '\n', 3, 7) ]), body=[ KeywordCall([ Token('SEPARATOR', ' ', 4, 0), Token('KEYWORD', 'Keyword', 4, 4), Token('SEPARATOR', ' ', 4, 11), Token('ARGUMENT', 'arg', 4, 15),