Fixed south test, only for django < 1.9

This commit is contained in:
DiogoMarques 2016-01-19 12:14:21 +00:00
parent 6573ef549f
commit d14876cbe1
2 changed files with 21 additions and 14 deletions

View file

@ -1,6 +1,7 @@
from django.db import models
from django import forms
from django.utils.translation import ugettext_lazy as _
from django import VERSION
from .backends import detect_backend, UnknownIdException, \
UnknownBackendException
@ -19,14 +20,15 @@ class EmbedVideoField(models.URLField):
defaults.update(kwargs)
return super(EmbedVideoField, self).formfield(**defaults)
def south_field_triple(self):
from south.modelsinspector import introspector
cls_name = '%s.%s' % (
self.__class__.__module__,
self.__class__.__name__
)
args, kwargs = introspector(self)
return (cls_name, args, kwargs)
if VERSION < (1, 9):
def south_field_triple(self):
from south.modelsinspector import introspector
cls_name = '%s.%s' % (
self.__class__.__module__,
self.__class__.__name__
)
args, kwargs = introspector(self)
return (cls_name, args, kwargs)
class EmbedVideoFormField(forms.URLField):

View file

@ -2,6 +2,7 @@ from mock import patch
from unittest import TestCase
from django.forms import ValidationError
from django import VERSION
from ..fields import EmbedVideoField, EmbedVideoFormField
from ..backends import UnknownBackendException, UnknownIdException, \
@ -16,12 +17,16 @@ class EmbedVideoFieldTestCase(TestCase):
self.assertIsInstance(self.field.formfield(),
EmbedVideoFormField)
def test_south(self):
self.assertEqual(self.field.south_field_triple(),
(
'embed_video.fields.EmbedVideoField',
[], {'max_length': '200'}
))
if VERSION < (1, 9):
def test_south(self):
self.assertEqual(
self.field.south_field_triple(),
(
'embed_video.fields.EmbedVideoField',
[],
{'max_length': '200'}
)
)
class EmbedVideoFormFieldTestCase(TestCase):