def assertSetEqual(self, set1, set2, msg=None):
try:<EOL><INDENT>difference1 = set1.difference(set2)<EOL><DEDENT>except TypeError as e:<EOL><INDENT>self.fail('<STR_LIT>' % e)<EOL><DEDENT>except AttributeError as e:<EOL><INDENT>self.fail('<STR_LIT>' % e)<EOL><DEDENT>try:<EOL><INDENT>difference2 = set2.difference(set1)<EOL><DEDENT>except TypeError as e:<EOL><INDENT>self.fail('<STR_LIT>' % e)<EOL><DEDENT>except AttributeError as e:<EOL><INDENT>self.fail('<STR_LIT>' % e)<EOL><DEDENT>if not (difference1 or difference2):<EOL><INDENT>return<EOL><DEDENT>lines = []<EOL>if difference1:<EOL><INDENT>lines.append('<STR_LIT>')<EOL>for item in difference1:<EOL><INDENT>lines.append(repr(item))<EOL><DEDENT><DEDENT>if difference2:<EOL><INDENT>lines.append('<STR_LIT>')<EOL>for item in difference2:<EOL><INDENT>lines.append(repr(item))<EOL><DEDENT><DEDENT>standardMsg = '<STR_LIT:\n>'.join(lines)<EOL>self.fail(self._formatMessage(msg, standardMsg))<EOL>
A set-specific equality assertion.

        Args:
            set1: The first set to compare.
            set2: The second set to compare.
            msg: Optional message to use on failure instead of a list of
                    differences.

        assertSetEqual uses ducktyping to support
        different types of sets, and is optimized for sets specifically
        (parameters must support a difference method).