Exemplo n.º 1
0
 def test_unsupported_unpickle(self):
     """
     #21430 -- Verifies a warning is raised for querysets that are
     unpickled with a different Django version than the current
     """
     qs = Group.previous_django_version_objects.all()
     with warnings.catch_warnings(record=True) as recorded:
         pickle.loads(pickle.dumps(qs))
         msg = force_text(recorded.pop().message)
         self.assertEqual(msg,
             "Pickled queryset instance's Django version %s does not "
             "match the current version %s."
             % (str(float(get_major_version()) - 0.1), get_version()))
Exemplo n.º 2
0
 def test_unsupported_unpickle(self):
     """
     #21430 -- Verifies a warning is raised for querysets that are
     unpickled with a different Django version than the current
     """
     qs = Group.previous_django_version_objects.all()
     with warnings.catch_warnings(record=True) as recorded:
         pickle.loads(pickle.dumps(qs))
         msg = force_text(recorded.pop().message)
         self.assertEqual(msg,
             "Pickled queryset instance's Django version %s does not "
             "match the current version %s."
             % (str(float(get_major_version()) - 0.1), get_version()))
Exemplo n.º 3
0
def get_version(version=None):
    "Return a PEP 386-compliant version number from VERSION."
    version = get_complete_version(version)

    # Now build the two parts of the version number:
    # main = X.Y[.Z]
    # sub = {a|b|rc}N - for alpha, beta and rc releases
    main = get_major_version(version)

    sub = ''
    if version[3] != 'final':
        mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'rc'}
        sub = mapping[version[3]] + str(version[4])

    return str(main + sub)
Exemplo n.º 4
0
def get_version(version=None):
    "Return a PEP 386-compliant version number from VERSION."
    version = get_complete_version(version)

    # Now build the two parts of the version number:
    # main = X.Y[.Z]
    # sub = {a|b|rc}N - for alpha, beta and rc releases
    main = get_major_version(version)

    sub = ''
    if version[3] != 'final':
        mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'rc'}
        sub = mapping[version[3]] + str(version[4])

    return str(main + sub)
Exemplo n.º 5
0
    def test_unsupported_unpickle(self):
        """
        #21430 -- Verifies a warning is raised for models that are
        unpickled with a different Django version than the current
        """
        class DifferentDjangoVersion(models.Model):
            title = models.CharField(max_length=10)

            def __reduce__(self):
                reduce_list = super(DifferentDjangoVersion, self).__reduce__()
                data = reduce_list[-1]
                data[DJANGO_VERSION_PICKLE_KEY] = str(float(get_major_version()) - 0.1)
                return reduce_list

        p = DifferentDjangoVersion(title="FooBar")
        with warnings.catch_warnings(record=True) as recorded:
            pickle.loads(pickle.dumps(p))
            msg = force_text(recorded.pop().message)
            self.assertEqual(msg,
                "Pickled model instance's Django version %s does not "
                "match the current version %s."
                % (str(float(get_major_version()) - 0.1), get_version()))
    def test_unsupported_unpickle(self):
        """
        #21430 -- Verifies a warning is raised for models that are
        unpickled with a different Django version than the current
        """
        class DifferentDjangoVersion(models.Model):
            title = models.CharField(max_length=10)

            def __reduce__(self):
                reduce_list = super(DifferentDjangoVersion, self).__reduce__()
                data = reduce_list[-1]
                data[DJANGO_VERSION_PICKLE_KEY] = str(
                    float(get_major_version()) - 0.1)
                return reduce_list

        p = DifferentDjangoVersion(title="FooBar")
        with warnings.catch_warnings(record=True) as recorded:
            pickle.loads(pickle.dumps(p))
            msg = force_text(recorded.pop().message)
            self.assertEqual(
                msg, "Pickled model instance's Django version %s does not "
                "match the current version %s." %
                (str(float(get_major_version()) - 0.1), get_version()))
 def __reduce__(self):
     reduce_list = super(DifferentDjangoVersion, self).__reduce__()
     data = reduce_list[-1]
     data[DJANGO_VERSION_PICKLE_KEY] = str(
         float(get_major_version()) - 0.1)
     return reduce_list
Exemplo n.º 8
0
 def __reduce__(self):
     reduce_list = super(DifferentDjangoVersion, self).__reduce__()
     data = reduce_list[-1]
     data[DJANGO_VERSION_PICKLE_KEY] = str(float(get_major_version()) - 0.1)
     return reduce_list
Exemplo n.º 9
0
 def __getstate__(self):
     state = super(PreviousDjangoVersionQuerySet, self).__getstate__()
     state[DJANGO_VERSION_PICKLE_KEY] = str(
         float(get_major_version()) - 0.1)  # previous major version
     return state
Exemplo n.º 10
0
 def __getstate__(self):
     state = super(PreviousDjangoVersionQuerySet, self).__getstate__()
     state[DJANGO_VERSION_PICKLE_KEY] = str(float(get_major_version()) - 0.1)  # previous major version
     return state