def test_it_should_parse_multiple_text_and_group_sections(self): feature = "\ foo\n\ |exampleA|\n\ bar\n\ |example1|example2|\n" tokens = GherkinParser(feature).parse() tokens.should.have.length_of(8) tokens[0].should.equal((Tokens.INDENT, Indent(Indent.SPACE, 4), {})) tokens[1].should.equal((Tokens.TEXT, 'foo', {})) tokens[2].should.equal((Tokens.NEWLINE, '\n', {})) group = tokens[3] group[0].should.equal(Tokens.GROUP) group[1].should.equal([['exampleA']]) tokens[4].should.equal((Tokens.INDENT, Indent(Indent.SPACE, 4), {})) tokens[5].should.equal((Tokens.TEXT, 'bar', {})) tokens[6].should.equal((Tokens.NEWLINE, '\n', {})) group = tokens[7] group[0].should.equal(Tokens.GROUP) group[1].should.equal([['example1', 'example2']])
def test_it_should_indent_example_groups_based_on_first_line(self): feature = "\ |example1|\n\ |example2|\n\ |example3|\n" tokens = GherkinParser(feature).parse() tokens.should.have.length_of(1) group = tokens[0] group[0].should.equal(Tokens.GROUP) group[1].should.equal([['example1'], ['example2'], ['example3']]) group[2].should.equal({'indent': Indent(Indent.SPACE, 6)})
def test_it_should_parse_text_and_groups(self): feature = "\ Feature: As a crazy cat person\n\ I want to write a list of cat breeds\n\ So that my codez is odd\n\ \n\ |cat breeds|country|\n\ |Manx|Isle of Man|\n\ |Octocat|The Web|\n" tokens = GherkinParser(feature).parse() tokens.should.have.length_of(12) tokens[0].should.equal((Tokens.INDENT, Indent(Indent.SPACE, 4), {})) tokens[1].should.equal( (Tokens.TEXT, 'Feature: As a crazy cat person', {})) tokens[2].should.equal((Tokens.NEWLINE, '\n', {})) tokens[3].should.equal((Tokens.INDENT, Indent(Indent.SPACE, 4), {})) tokens[4].should.equal( (Tokens.TEXT, 'I want to write a list of cat breeds', {})) tokens[5].should.equal((Tokens.NEWLINE, '\n', {})) tokens[6].should.equal((Tokens.INDENT, Indent(Indent.SPACE, 4), {})) tokens[7].should.equal((Tokens.TEXT, 'So that my codez is odd', {})) tokens[8].should.equal((Tokens.NEWLINE, '\n', {})) tokens[9].should.equal((Tokens.INDENT, Indent(Indent.SPACE, 4), {})) tokens[10].should.equal((Tokens.NEWLINE, '\n', {})) group = tokens[11] group[0].should.equal(Tokens.GROUP) examples = group[1] examples.should.have.length_of(3) examples[0].should.equal(['cat breeds', 'country']) examples[1].should.equal(['Manx', 'Isle of Man']) examples[2].should.equal(['Octocat', 'The Web'])
def test_it_should_parse_non_example_tables_as_text(self): feature = "\ Feature: As a tester\n\ I want my non example table text to remain intact\n\ So that I don't want to kill the author of this plugin" tokens = GherkinParser(feature).parse() tokens.should.have.length_of(9) tokens[0].should.equal((Tokens.INDENT, Indent(Indent.SPACE, 4), {})) tokens[1].should.equal((Tokens.TEXT, 'Feature: As a tester', {})) tokens[2].should.equal((Tokens.NEWLINE, '\n', {})) tokens[3].should.equal((Tokens.INDENT, Indent(Indent.SPACE, 4), {})) tokens[4].should.equal( (Tokens.TEXT, 'I want my non example table text to remain intact', {})) tokens[5].should.equal((Tokens.NEWLINE, '\n', {})) tokens[6].should.equal((Tokens.INDENT, Indent(Indent.SPACE, 4), {})) tokens[7].should.equal( (Tokens.TEXT, 'So that I don\'t want to kill the author of this plugin', {})) tokens[8].should.equal((Tokens.NEWLINE, '\n', {}))
def test_detect(self): Indent.detect(' foo').should.equal(Indent(Indent.SPACE, 2)) Indent.detect('\tfoo').should.equal(Indent(Indent.TAB, 1)) Indent.detect('foo').should.equal(None)
def test_str(self): str(Indent(Indent.SPACE, 4)).should.equal(' ') str(Indent(Indent.TAB, 2)).should.equal('\t\t') self.assertRaises(RuntimeError, Indent(999, 1).__str__)
def test_equality(self): Indent(Indent.SPACE, 4).should.equal(Indent(Indent.SPACE, 4))