def test_defaultrecursion(self):
        class RecursiveJSONEncoder(self.json.JSONEncoder):
            recurse = False
            def default(self, o):
                if o is JSONTestObject:
                    if self.recurse:
                        return [JSONTestObject]
                    else:
                        return 'JSONTestObject'
                return pyjson.JSONEncoder.default(o)

        enc = RecursiveJSONEncoder()
        self.assertEqual(enc.encode(JSONTestObject), '"JSONTestObject"')
        enc.recurse = True
        try:
            enc.encode(JSONTestObject)
        except __HOLE__:
            pass
        else:
            self.fail("didn't raise ValueError on default recursion")
dataset/ETHPy150Open amrdraz/kodr/app/brython/www/src/Lib/test/test_json/test_recursion.py/TestRecursion.test_defaultrecursion