def test_is_produced(self):
        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 ValueError as e:
            self.failUnlessEqual(e.args, ('Object is not instance of ChildObj but ChildObj',))
        else:
            self.fail('ValueError not raised')
Reset state variables used for each pass.
dataset/ETHPy150Open mission-liao/pyswagger/pyswagger/tests/test_base.py/SwaggerBaseTestCase.test_is_produced--crossover with--dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/virt/libvirt/imagecache.py/ImageCacheManager._reset_state