Exemple #1
0
 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,
     )
Exemple #2
0
 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)
Exemple #3
0
 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)
Exemple #4
0
 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)
Exemple #5
0
    def _parse_plan(self, match):
        """Parse a matching plan line."""
        expected_tests = int(match.group('expected'))
        directive = Directive(match.group('directive'))

        # Only SKIP directives are allowed in the plan.
        if directive.text and not directive.skip:
            return Unknown()

        return Plan(expected_tests, directive)
Exemple #6
0
 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)
Exemple #7
0
    def test_todo_has_boundary(self):
        """TAP spec indicates TODO directives must be on a boundary."""
        text = "TODO: Not a TODO directive because of an immediate colon."
        directive = Directive(text)

        self.assertFalse(directive.todo)
Exemple #8
0
 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')))
Exemple #9
0
 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))
Exemple #10
0
    def test_finds_todo(self):
        text = "ToDo This is something to do."
        directive = Directive(text)

        self.assertTrue(directive.todo)
Exemple #11
0
    def test_skip_at_beginning(self):
        """Only match SKIP directives at the beginning."""
        text = "This is not something to skip."
        directive = Directive(text)

        self.assertFalse(directive.skip)
Exemple #12
0
    def test_finds_simplest_skip(self):
        text = "SKIP"
        directive = Directive(text)

        self.assertTrue(directive.skip)
Exemple #13
0
 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))
Exemple #14
0
 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))
Exemple #15
0
    def test_finds_simplest_todo(self):
        text = "TODO"
        directive = Directive(text)

        self.assertTrue(directive.todo)
Exemple #16
0
 def make_plan(self, expected_tests=99, directive_text=""):
     return Plan(expected_tests, Directive(directive_text))
Exemple #17
0
 def make_not_ok(self, directive_text=""):
     return Result(False, 1, "This is a description.",
                   Directive(directive_text))
Exemple #18
0
 def make_not_ok(self, directive_text=''):
     return Result(False, 1, 'This is a description.',
                   Directive(directive_text))
Exemple #19
0
 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))
Exemple #20
0
    def test_finds_skip(self):
        text = "Skipping This is something to skip."
        directive = Directive(text)

        self.assertTrue(directive.skip)