def test_is_produced(self):
        """ test is_produced function """
        class ChildNotOkContext(base.Context):
            __swagger_ref_object__ = ChildObj

            @classmethod
            def is_produced(kls, obj):
                return False

        class TestOkContext(base.Context):
            __swagger_ref_object__ = TestObj
            __swagger_child__ = {
                'a': (None, ChildContext)
            }

        class TestNotOkContext(base.Context):
            __swagger_ref_object__ = TestObj
            __swagger_child__ = {
                'a': (None, ChildNotOkContext)
            }

        tmp = {'t': {}}
        obj = {'a': {}}

        with TestOkContext(tmp, 't') as ctx:
            # should not raise
            ctx.parse(obj)

        ctx = TestNotOkContext(tmp, 't')
        try:
            # simulate what ContextManager does
            ctx.parse(obj)
            ctx.__exit__(None, None, None)
        except __HOLE__ as e:
            self.failUnlessEqual(e.args, ('Object is not instance of ChildObj but ChildObj',))
        else:
            self.fail('ValueError not raised')
dataset/ETHPy150Open mission-liao/pyswagger/pyswagger/tests/test_base.py/SwaggerBaseTestCase.test_is_produced