def test_masking_existing_user_attribute_when_verbose_causes_warning(self):
        warns = []

        def catch_warning(*args, **kwargs):
            warns.append(args[0])

        old_showwarning = warnings.showwarning
        warnings.showwarning = catch_warning

        # pylint: disable=protected-access
        self.config.verbose = True
        with self.context.use_with_user_mode():
            self.context.thing = "stuff"
            self.context._push()
            self.context.thing = "other stuff"

        warnings.showwarning = old_showwarning

        print(repr(warns))
        assert warns, "warns is empty!"
        warning = warns[0]
        assert isinstance(warning, runner.ContextMaskWarning), "warning is not a ContextMaskWarning"
        info = warning.args[0]
        assert info.startswith("user code"), "%r doesn't start with 'user code'" % info
        assert "'thing'" in info, "%r not in %r" % ("'thing'", info)
        assert "tutorial" in info, '"tutorial" not in %r' % (info, )
dataset/ETHPy150Open behave/behave/test/test_runner.py/TestContext.test_masking_existing_user_attribute_when_verbose_causes_warning/original