# Path: rmr/utils/test.py
# def data_provider(*data_sets):
#     warnings.warn(
#         'data_provider is deprecated and will be removed in rmr-django 2.0, '
#         'use unittest.TestCase.subTest instead',
#         DeprecationWarning,
#     )
# 
#     def _decorator(test_method):
#         test_method.__data_sets__ = data_sets
#         return test_method
# 
#     return _decorator
# 
# class DataSet:
# 
#     def __init__(self, *args, **kwargs):
#         self.args = args
#         self.kwargs = kwargs
#         warnings.warn(
#             'DataSet is deprecated and will be removed in rmr-django 2.0, '
#             'use unittest.TestCase.subTest instead',
#             DeprecationWarning,
#         )
# 
#     def __str__(self):
#         return '(args={}, kwargs={})'.format(self.args, self.kwargs)
# 
# class Parametrized(type):
# 
#     def __new__(mcs, name, mro, attrs):
#         warnings.warn(
#             'Parametrized metaclass is deprecated and will be removed '
#             'in rmr-django 2.0, use unittest.TestCase.subTest instead',
#             category=RuntimeWarning, stacklevel=2,
#         )
# 
#         actual_attrs = {}
#         for method_name, method in attrs.items():
#             data_sets = getattr(method, '__data_sets__', None)
#             if not data_sets:
#                 actual_attrs[method_name] = method
#                 continue
#             for data_set in data_sets:
#                 test_name = '{}_{}'.format(method_name, data_set)
#                 actual_attrs[test_name] = (lambda m, ds: (
#                     lambda self: m(self, *ds.args, **ds.kwargs)
#                 ))(method, data_set)
#         return super().__new__(mcs, name, mro, actual_attrs)


import django.http
import django.test
import rmr.views
from django.conf.urls import url
from django.test.utils import override_settings
from django.views.generic import View
from rmr.utils.test import data_provider, DataSet, Parametrized

    def test_wrong_charset(self):
        response = self.client.post(
            '/simple',
            data=b'\xd0',
            content_type='application/json',
        )
        self.assertIsInstance(response, django.http.HttpResponseBadRequest)
        self.assertEqual(b'bad unicode', response.content)

    @data_provider(
        DataSet(data='"'),
        DataSet(data='{'),
        DataSet(data=']'),
        DataSet(data='hello'),
        DataSet(data='hello=world'),
    )
    def test_wrong_json(self, data):
        response = self.client.post(
            '/simple',
            data=data,
            content_type='application/json',
        )
        self.assertIsInstance(response, django.http.HttpResponseBadRequest)
        self.assertEqual(b'malformed data', response.content)

    @data_provider(
        DataSet(request_data='{"a": 1}', response_data=b'{"a": 1}'),
        DataSet(request_data='{}', response_data=b'{}'),
        DataSet(request_data='""', response_data=b'""'),

# Path: rmr/utils/test.py
# def data_provider(*data_sets):
#     warnings.warn(
#         'data_provider is deprecated and will be removed in rmr-django 2.0, '
#         'use unittest.TestCase.subTest instead',
#         DeprecationWarning,
#     )
# 
#     def _decorator(test_method):
#         test_method.__data_sets__ = data_sets
#         return test_method
# 
#     return _decorator
# 
# class DataSet:
# 
#     def __init__(self, *args, **kwargs):
#         self.args = args
#         self.kwargs = kwargs
#         warnings.warn(
#             'DataSet is deprecated and will be removed in rmr-django 2.0, '
#             'use unittest.TestCase.subTest instead',
#             DeprecationWarning,
#         )
# 
#     def __str__(self):
#         return '(args={}, kwargs={})'.format(self.args, self.kwargs)
# 
# class Parametrized(type):
# 
#     def __new__(mcs, name, mro, attrs):
#         warnings.warn(
#             'Parametrized metaclass is deprecated and will be removed '
#             'in rmr-django 2.0, use unittest.TestCase.subTest instead',
#             category=RuntimeWarning, stacklevel=2,
#         )
# 
#         actual_attrs = {}
#         for method_name, method in attrs.items():
#             data_sets = getattr(method, '__data_sets__', None)
#             if not data_sets:
#                 actual_attrs[method_name] = method
#                 continue
#             for data_set in data_sets:
#                 test_name = '{}_{}'.format(method_name, data_set)
#                 actual_attrs[test_name] = (lambda m, ds: (
#                     lambda self: m(self, *ds.args, **ds.kwargs)
#                 ))(method, data_set)
#         return super().__new__(mcs, name, mro, actual_attrs)


# Path: tests/middleware/test_json.py
import django.http
import django.test
import rmr.views
from django.conf.urls import url
from django.test.utils import override_settings
from django.views.generic import View
from rmr.utils.test import data_provider, DataSet, Parametrized


    def test_wrong_charset(self):
        response = self.client.post(
            '/simple',
            data=b'\xd0',
            content_type='application/json',
        )
        self.assertIsInstance(response, django.http.HttpResponseBadRequest)
        self.assertEqual(b'bad unicode', response.content)

    @data_provider(
        DataSet(data='"'),
        DataSet(data='{'),
        DataSet(data=']'),
        DataSet(data='hello'),
        DataSet(data='hello=world'),
    )
    def test_wrong_json(self, data):
        response = self.client.post(
            '/simple',
            data=data,
            content_type='application/json',
        )
        self.assertIsInstance(response, django.http.HttpResponseBadRequest)
        self.assertEqual(b'malformed data', response.content)

    @data_provider(
        DataSet(request_data='{"a": 1}', response_data=b'{"a": 1}'),
        DataSet(request_data='{}', response_data=b'{}'),
        DataSet(request_data='""', response_data=b'""'),

        DataSet(request_data='"foo"', response_data=b'"foo"'),