Пример #1
0
 def test_parent(self):
     # The parent can be retrieved from a child context.
     parent = TagContext()
     parent.change_tags({'foo'}, set())
     child = TagContext(parent)
     child.change_tags(set(), {'foo'})
     self.assertEqual(parent, child.parent)
Пример #2
0
 def test_child_context(self):
     # A TagContext can have a parent.  If so, its tags are the tags of the
     # parent at the moment of construction.
     parent = TagContext()
     parent.change_tags(set(['foo']), set())
     child = TagContext(parent)
     self.assertEqual(parent.get_current_tags(), child.get_current_tags())
Пример #3
0
 def test_add_to_child(self):
     # Adding a tag to the child context doesn't affect the parent.
     parent = TagContext()
     parent.change_tags({'foo'}, set())
     child = TagContext(parent)
     child.change_tags({'bar'}, set())
     self.assertEqual({'foo', 'bar'}, child.get_current_tags())
     self.assertEqual({'foo'}, parent.get_current_tags())
Пример #4
0
 def test_remove_in_child(self):
     # A tag that was in the parent context can be removed from the child
     # context without affect the parent.
     parent = TagContext()
     parent.change_tags({'foo'}, set())
     child = TagContext(parent)
     child.change_tags(set(), {'foo'})
     self.assertEqual(set(), child.get_current_tags())
     self.assertEqual({'foo'}, parent.get_current_tags())
Пример #5
0
 def test_add_tag_twice(self):
     # Calling change_tags twice to add tags adds both tags to the current
     # tags.
     tag_context = TagContext()
     tag_context.change_tags(set(['foo']), set())
     tag_context.change_tags(set(['bar']), set())
     self.assertEqual(set(['foo', 'bar']), tag_context.get_current_tags())
Пример #6
0
    def startTestRun(self):
        """Called before a test run starts.

        New in Python 2.7. The testtools version resets the result to a
        pristine condition ready for use in another test run.  Note that this
        is different from Python 2.7's startTestRun, which does nothing.
        """
        # failfast is reset by the super __init__, so stash it.
        failfast = self.failfast
        super(TestResult, self).__init__()
        self.skip_reasons = {}
        self.__now = None
        self._tags = TagContext()
        # -- Start: As per python 2.7 --
        self.expectedFailures = []
        self.unexpectedSuccesses = []
        self.failfast = failfast
Пример #7
0
 def test_remove_tag(self):
     # change_tags can remove tags from the context.
     tag_context = TagContext()
     tag_context.change_tags({'foo'}, set())
     tag_context.change_tags(set(), {'foo'})
     self.assertEqual(set(), tag_context.get_current_tags())
Пример #8
0
 def test_change_tags_returns_tags(self):
     # change_tags returns the current tags.  This is a convenience.
     tag_context = TagContext()
     tags = tag_context.change_tags({'foo'}, set())
     self.assertEqual({'foo'}, tags)
Пример #9
0
 def test_add_tag(self):
     # A tag added with change_tags appears in get_current_tags.
     tag_context = TagContext()
     tag_context.change_tags({'foo'}, set())
     self.assertEqual({'foo'}, tag_context.get_current_tags())
Пример #10
0
 def __init__(self, decorated):
     self.decorated = decorated
     self._tags = TagContext()
     # Only used for old TestResults that do not have failfast.
     self._failfast = False
Пример #11
0
 def startTest(self, test):
     super(ExtendedTestResult, self).startTest(test)
     self._tags = TagContext(self._tags)
Пример #12
0
 def __init__(self, event_log=None):
     super().__init__(event_log)
     self._tags = TagContext()
Пример #13
0
 def startTest(self, test):
     super().startTest(test)
     self._tags = TagContext(self._tags)
Пример #14
0
 def startTestRun(self):
     super().startTestRun()
     self._was_successful = True
     self._tags = TagContext()
Пример #15
0
 def startTestRun(self):
     self._tags = TagContext()
     try:
         return self.decorated.startTestRun()
     except AttributeError:
         return
Пример #16
0
 def startTest(self, test):
     self._tags = TagContext(self._tags)
     return self.decorated.startTest(test)
Пример #17
0
 def startTestRun(self):
     super(ExtendedTestResult, self).startTestRun()
     self._was_successful = True
     self._tags = TagContext()
Пример #18
0
 def __init__(self):
     super(ExtendedTestResult, self).__init__()
     self._tags = TagContext()
Пример #19
0
 def __init__(self, event_log=None):
     super(ExtendedTestResult, self).__init__(event_log)
     self._tags = TagContext()
Пример #20
0
 def test_no_tags(self):
     # A tag context has no tags initially.
     tag_context = TagContext()
     self.assertEqual(set(), tag_context.get_current_tags())