def test_with_combined_expression(self):
        """Testing serialize_to_python with CombinedExpression"""
        if not can_test_combined_expressions:
            raise SkipTest('Not supported on this version of Django')

        self.assertEqual(
            deserialize_from_signature({
                '_deconstructed': True,
                'args': (
                    {
                        '_deconstructed': True,
                        'args': ('a',),
                        'kwargs': {},
                        'type': 'django.db.models.expressions.F',
                    },
                    '+',
                    {
                        '_deconstructed': True,
                        'args': (1,),
                        'kwargs': {},
                        'type': 'django.db.models.expressions.Value',
                    },
                ),
                'kwargs': {},
                'type': 'django.db.models.expressions.CombinedExpression',
            }),
            F('a') + 1)
 def test_with_q(self):
     """Testing deserialize_from_signature with Q"""
     self.assertEqual(
         deserialize_from_signature({
             '_deconstructed': True,
             'args': [
                 {
                     '_deconstructed': True,
                     'args': [
                         ['field1', True],
                     ],
                     'kwargs': {
                         '_negated': True,
                     },
                     'type': 'django.db.models.Q',
                 },
                 {
                     '_deconstructed': True,
                     'args': [
                         ['field2', 'test'],
                         ['field3__gte', 1],
                     ],
                     'kwargs': {
                         '_connector': 'OR',
                     },
                     'type': 'django.db.models.Q'
                 },
             ],
             'kwargs': {},
             'type': 'django.db.models.Q',
         }),
         ~Q(field1=True) & (Q(field2='test') | Q(field3__gte=1)))
 def test_with_q_empty(self):
     """Testing deserialize_from_signature with empty Q"""
     self.assertEqual(
         deserialize_from_signature({
             '_deconstructed': True,
             'args': [],
             'kwargs': {},
             'type': 'django.db.models.Q',
         }),
         Q())
    def test_with_deferrable(self):
        """Testing deserialize_from_signature with Deferrable enum value"""
        if Deferrable is None:
            raise SkipTest('Not supported on this version of Django')

        self.assertEqual(
            deserialize_from_signature({
                '_enum': True,
                'type': 'django.db.models.Deferrable',
                'value': 'DEFERRED',
            }),
            Deferrable.DEFERRED)
 def test_with_q_kwargs(self):
     """Testing deserialize_from_signature with Q and fields in kwargs"""
     self.assertEqual(
         deserialize_from_signature({
             '_deconstructed': True,
             'args': [],
             'kwargs': {
                 'field1': True,
                 '_negated': True,
             },
             'type': 'django.db.models.Q',
         }),
         ~Q(field1=True))
 def test_with_deconstructable_obj(self):
     """Testing deserialize_from_signature with deconstructable object"""
     self.assertEqual(
         deserialize_from_signature({
             '_deconstructed': True,
             'args': (1, 2, 3),
             'kwargs': {
                 'kwarg1': 'value1',
                 'kwarg2': 'value2',
             },
             'type': ('django_evolution.tests.test_serialization.'
                      'MyDeconstructableObject'),
         }),
         MyDeconstructableObject(1, 2, 3,
                                 kwarg1='value1',
                                 kwarg2='value2'))
    def test_with_ordered_dict(self):
        """Testing deserialize_from_signature with dict"""
        d = OrderedDict()
        d['a'] = 'value1'
        d['c'] = [1, 2, 3]
        d['b'] = None

        result = deserialize_from_signature(d)
        self.assertIsInstance(result, dict)
        self.assertEqual(
            result,
            {
                'a': 'value1',
                'c': [1, 2, 3],
                'b': None,
            })
 def test_with_dict(self):
     """Testing deserialize_from_signature with dict"""
     self.assertEqual(
         deserialize_from_signature({
             'a': 'value1',
             'c': [1, 2, 3],
             'b': {
                 'nested': None,
             },
         }),
         {
             'a': 'value1',
             'c': [1, 2, 3],
             'b': {
                 'nested': None,
             },
         })
 def test_with_float(self):
     """Testing deserialize_from_signature with float"""
     self.assertEqual(deserialize_from_signature(1.23), 1.23)
 def test_with_bool(self):
     """Testing deserialize_from_signature with bool"""
     self.assertIs(deserialize_from_signature(True), True)
 def test_with_unicode_str(self):
     """Testing deserialize_from_signature with unicode string"""
     self.assertEqual(deserialize_from_signature('test 🧸'), 'test 🧸')
 def test_with_type(self):
     """Testing deserialize_from_signature with type"""
     with self.assertRaises(NotImplementedError):
         deserialize_from_signature(CharField)
 def test_with_tuple(self):
     """Testing deserialize_from_signature with tuple"""
     self.assertEqual(deserialize_from_signature((1, True, 'foo')),
                      (1, True, 'foo'))
 def test_with_set(self):
     """Testing deserialize_from_signature with set"""
     self.assertEqual(deserialize_from_signature({1, 3, 2}),
                      {1, 2, 3})
 def test_with_int(self):
     """Testing deserialize_from_signature with int"""
     self.assertEqual(deserialize_from_signature(123), 123)
 def test_with_list(self):
     """Testing deserialize_from_signature with list"""
     self.assertEqual(deserialize_from_signature([1, 2, 'foo']),
                      [1, 2, 'foo'])
    def test_with_long(self):
        """Testing deserialize_from_signature with long"""
        if not six.PY2:
            raise SkipTest('Applicable on Python 2 only.')

        self.assertEqual(deserialize_from_signature(long(123)), long(123))
 def test_with_placeholder(self):
     """Testing deserialize_from_signature with BasePlaceholder subclass"""
     with self.assertRaises(NotImplementedError):
         deserialize_from_signature(NullFieldInitialCallback())
 def test_with_none(self):
     """Testing deserialize_from_signature with None"""
     self.assertIsNone(deserialize_from_signature(None))