1 # Copyright (c) 2012 testtools developers. See LICENSE for details.
6 class TagContext(object):
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.
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.
32 self
._tags
.update(new_tags
)
33 self
._tags
.difference_update(gone_tags
)
34 return self
.get_current_tags()