Remove bundled subunit.
[samba.git] / lib / testtools / testtools / tags.py
1 # Copyright (c) 2012 testtools developers. See LICENSE for details.
2
3 """Tag support."""
4
5
6 class TagContext(object):
7     """A tag context."""
8
9     def __init__(self, parent=None):
10         """Create a new TagContext.
11
12         :param parent: If provided, uses this as the parent context.  Any tags
13             that are current on the parent at the time of construction are
14             current in this context.
15         """
16         self.parent = parent
17         self._tags = set()
18         if parent:
19             self._tags.update(parent.get_current_tags())
20
21     def get_current_tags(self):
22         """Return any current tags."""
23         return set(self._tags)
24
25     def change_tags(self, new_tags, gone_tags):
26         """Change the tags on this context.
27
28         :param new_tags: A set of tags to add to this context.
29         :param gone_tags: A set of tags to remove from this context.
30         :return: The tags now current on this context.
31         """
32         self._tags.update(new_tags)
33         self._tags.difference_update(gone_tags)
34         return self.get_current_tags()