def test_feature_with_lone_comment(self): input = 'i be a newbie feature' language = self._get_language() p = Parser(language=language) try: p.parse_feature(input) assert False # should fail! # pragma: nocover except SyntaxError as e: e = e.args[0] try: feature_name = TRANSLATIONS[language].get('feature', self.feature_keyword) except KeyError: feature_name = self.feature_keyword else: feature_name = feature_name.replace('|', ' or ') self.assert_regex_contains(r'feature files must start with a %s' % feature_name, e)
def test_feature_with_long_comment(self): # ERGO how to detect shadowed test cases?? language = self._get_language() p = Parser(language=language) input = '''%s: The Sacred Giant Mosquito of the Andes # at http://www.onagocag.com/nazbird.jpg so pay no attention to the skeptics!''' % self.feature_keyword try: p.parse_feature(input) assert False # should raise a SyntaxError # pragma: nocover except SyntaxError as e: self.assert_regex_contains('linefeed in comment', str(e)) self.assert_regex_contains('line 2', str(e)) steps = p.steps assert steps[0].__class__ == Feature step = steps[1] assert step.__class__ == Comment self.assertEqual(step.keyword, '#')
def test_file_without_feature_defined(self): input = 'i be a newbie feature' language = self._get_language() p = Parser(language=language) try: p.parse_feature(input) assert False # should fail! # pragma: nocover except SyntaxError as e: e = e.args[0] try: feature_name = TRANSLATIONS[language].get( 'feature', self.feature_keyword) except KeyError: feature_name = self.feature_keyword else: feature_name = feature_name.replace('|', ' or ') self.assert_regex_contains( r'feature files must start with a %s' % feature_name, e)
def test_feature_with_long_comment( self): # ERGO how to detect shadowed test cases?? language = self._get_language() p = Parser(language=language) input = '''%s: The Sacred Giant Mosquito of the Andes # at http://www.onagocag.com/nazbird.jpg so pay no attention to the skeptics!''' % self.feature_keyword try: p.parse_feature(input) assert False # should raise a SyntaxError # pragma: nocover except SyntaxError as e: self.assert_regex_contains('linefeed in comment', str(e)) self.assert_regex_contains('line 2', str(e)) steps = p.steps assert steps[0].__class__ == Feature step = steps[1] assert step.__class__ == Comment self.assertEqual(step.keyword, '#')
def test_parse_feature_Row(self): language = self._get_language() p = Parser(language=language) p.parse_feature(''' | piggy | op |''') assert Row == p.steps[0].__class__ assert p.steps[0].predicate == 'piggy | op |'