def _test(self, name, dp, method, args, request, reply, expected):
        print('processing %s ...' % name)
        waiters = {}
        dp.set_reply(reply, waiters)
        if reply:
            output = method(dp=dp, waiters=waiters, **args)
        else:
            output = method(dp=dp, **args)

        # expected message <--> sent message
        request.serialize()
        try:
            eq_(json.dumps(request.to_jsondict(), sort_keys=True),
                json.dumps(dp.request_msg.to_jsondict(), sort_keys=True))
        except AssertionError as e:
            # For debugging
            json.dump(dp.request_msg.to_jsondict(),
                      open('/tmp/' + name + '_request.json', 'w'),
                      indent=3, sort_keys=True)
            raise e

        # expected output <--> return of ofctl
        def _remove(d, names):
            def f(x):
                return _remove(x, names)

            if isinstance(d, list):
                return list(map(f, d))
            if isinstance(d, dict):
                d2 = {}
                for k, v in d.items():
                    if k in names:
                        continue
                    d2[k] = f(v)
                return d2
            return d

        expected = _remove(expected, ['len', 'length'])
        output = _remove(output, ['len', 'length'])
        try:
            eq_(json.dumps(expected, sort_keys=True),
                json.dumps(output, sort_keys=True))
        except AssertionError as e:
            # For debugging
            json.dump(output, open('/tmp/' + name + '_reply.json', 'w'),
                      indent=4)
            raise e
dataset/ETHPy150Open osrg/ryu/ryu/tests/unit/lib/test_ofctl.py/Test_ofctl._test/original