def _parse_result(self, ok, match, fh=None): """Parse a matching result line into a result instance.""" peek_match = None try: if fh is not None and ENABLE_VERSION_13 and isinstance( fh, peekable): peek_match = self.yaml_block_start.match(fh.peek()) except StopIteration: pass if peek_match is None: return Result( ok, number=match.group("number"), description=match.group("description").strip(), directive=Directive(match.group("directive")), ) indent = peek_match.group("indent") concat_yaml = self._extract_yaml_block(indent, fh) return Result( ok, number=match.group("number"), description=match.group("description").strip(), directive=Directive(match.group("directive")), raw_yaml_block=concat_yaml, )
def add_not_ok( self, class_name, description, directive='', diagnostics=None): result = Result( ok=False, number=self._get_next_line_number(class_name), description=description, diagnostics=diagnostics, directive=Directive(directive)) self._add_line(class_name, result)
def add_skip(self, class_name, description, reason): directive = 'SKIP {0}'.format(reason) result = Result(ok=True, number=self._get_next_line_number(class_name), description=description, directive=Directive(directive)) self._add_line(class_name, result)
def add_ok(self, class_name, description, directive=""): result = Result( ok=True, number=self._get_next_line_number(class_name), description=description, directive=Directive(directive), ) self._add_line(class_name, result)
def _parse_result(self, ok, match, fh=None): """Parse a matching result line into a result instance.""" peek_match = None try: if fh is not None and self._try_peeking: peek_match = self.yaml_block_start.match(fh.peek()) except StopIteration: pass if peek_match is None: return Result(ok, number=match.group('number'), description=match.group('description').strip(), directive=Directive(match.group('directive'))) indent = peek_match.group('indent') concat_yaml = self._extract_yaml_block(indent, fh) return Result(ok, number=match.group('number'), description=match.group('description').strip(), directive=Directive(match.group('directive')), raw_yaml_block=concat_yaml)
def add_not_ok(self, class_name, description, directive=''): result = Result(ok=False, number=self._get_next_line_number(class_name), description=description) self._add_line(class_name, result)
def test_str_directive(self): directive = Directive('SKIP a reason') result = Result(True, 44, 'passing', directive) self.assertEqual('ok 44 - passing # SKIP a reason', str(result))
def _parse_result(self, ok, match): """Parse a matching result line into a result instance.""" return Result(ok, match.group('number'), match.group('description').strip(), Directive(match.group('directive')))
def test_str_ok(self): result = Result(True, 42, 'passing') self.assertEqual('ok 42 - passing', str(result))
def test_str_not_ok(self): result = Result(False, 43, 'failing') self.assertEqual('not ok 43 - failing', str(result))
def test_category(self): result = Result(True) self.assertEqual('test', result.category)
def test_ok(self): result = Result(True) self.assertTrue(result.ok)
def handle_skipping_plan(self, skip_plan): """Handle a plan that contains a SKIP directive.""" skip_line = Result(True, None, skip_plan.directive.text, Directive("SKIP")) self._suite.addTest(Adapter(self._filename, skip_line))
def test_str_ok(self): result = Result(True, 42, "passing") self.assertEqual("ok 42 passing", str(result))
def make_not_ok(self, directive_text=""): return Result(False, 1, "This is a description.", Directive(directive_text))
def test_str_not_ok(self): result = Result(False, 43, "failing") self.assertEqual("not ok 43 failing", str(result))
def test_str_directive(self): directive = Directive("SKIP a reason") result = Result(True, 44, "passing", directive) self.assertEqual("ok 44 passing # SKIP a reason", str(result))
def make_not_ok(self, directive_text=''): return Result(False, 1, 'This is a description.', Directive(directive_text))
def test_str_diagnostics(self): result = Result(False, 43, "failing", diagnostics="# more info") self.assertEqual("not ok 43 failing\n# more info", str(result))
def _add_error(self, message): """Add an error test to the suite.""" error_line = Result(False, None, message, Directive("")) self._suite.addTest(Adapter(self._filename, error_line))
def test_str_diagnostics(self): result = Result(False, 43, 'failing', diagnostics='# more info') self.assertEqual('not ok 43 failing\n# more info', str(result))