dsdb: reset schema->{classes,attributes}_to_remove_size to 0
[Samba/gebeck_regimport.git] / lib / testtools / testtools / tags.py
blobb55bd38667b2b57581a17070061c5e25fbe8c688
1 # Copyright (c) 2012 testtools developers. See LICENSE for details.
3 """Tag support."""
6 class TagContext(object):
7 """A tag context."""
9 def __init__(self, parent=None):
10 """Create a new TagContext.
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())
21 def get_current_tags(self):
22 """Return any current tags."""
23 return set(self._tags)
25 def change_tags(self, new_tags, gone_tags):
26 """Change the tags on this context.
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()