Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'feature/python3'

  • Loading branch information...
commit deb9dc5bc55877fd21e59555522efc982b44d96b 2 parents 8ced47b + 1c7361e
@vandersonmota authored
View
4 model_mommy/generators.py
@@ -53,7 +53,7 @@ def gen_from_list(L):
class KidMommy(Mommy):
attr_mapping = {'some_field':gen_from_list([A, B, C])}
'''
- return lambda: choice(L)
+ return lambda: choice(list(L))
# -- DEFAULT GENERATORS --
@@ -96,7 +96,7 @@ def gen_string(max_length):
def gen_slug(max_length=50):
- valid_chars = string.letters + string.digits + '_-'
+ valid_chars = string.ascii_letters + string.digits + '_-'
return u''.join(choice(valid_chars) for i in range(max_length))
View
4 model_mommy/mommy.py
@@ -21,8 +21,8 @@
except ImportError:
BigIntegerField = IntegerField
-import generators
-from exceptions import ModelNotFound, AmbiguousModelName, InvalidQuantityException
+from . import generators
+from .exceptions import ModelNotFound, AmbiguousModelName, InvalidQuantityException
from six import string_types
View
8 model_mommy/recipe.py
@@ -1,7 +1,7 @@
#coding: utf-8
import inspect
-import mommy
-from exceptions import RecipeNotFound
+from . import mommy
+from .exceptions import RecipeNotFound
from six import string_types
@@ -22,7 +22,7 @@ def _mapping(self, new_attrs):
mapping[k] = v()
elif isinstance(v, RecipeForeignKey):
a={}
- for key, value in rel_fields_attrs.items():
+ for key, value in list(rel_fields_attrs.items()):
if key.startswith('%s__' % k):
a[key] = rel_fields_attrs.pop(key)
recipe_attrs = mommy.filter_rel_attrs(k, **a)
@@ -64,5 +64,3 @@ def foreign_key(recipe):
def seq(value, increment_by=1):
return mommy.Sequence(value, increment_by=increment_by)
-
-
View
4 test/generic/models.py
@@ -12,7 +12,7 @@
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
-from fields import *
+from .fields import *
from model_mommy.timezone import smart_datetime as datetime
# check whether or not PIL is installed
@@ -138,7 +138,7 @@ class DummyDefaultFieldsModel(models.Model):
default_int_field = models.IntegerField(default=123)
default_float_field = models.FloatField(default=123.0)
default_date_field = models.DateField(default='2012-01-01')
- default_date_time_field = models.DateTimeField(default=datetime(2012, 01, 01))
+ default_date_time_field = models.DateTimeField(default=datetime(2012, 1, 1))
default_time_field = models.TimeField(default='00:00:00')
default_decimal_field = models.DecimalField(max_digits=5, decimal_places=2,
default=Decimal('0'))
View
8 test/generic/tests/__init__.py
@@ -1,5 +1,5 @@
#coding: utf-8
-from test_mommy import *
-from test_extending_mommy import *
-from test_filling_fields import *
-from test_recipes import *
+from .test_mommy import *
+from .test_extending_mommy import *
+from .test_filling_fields import *
+from .test_recipes import *
View
6 test/generic/tests/test_filling_fields.py
@@ -23,7 +23,7 @@
pass
#BigIntegerField = IntegerField
-from six import text_type
+from six import text_type, string_types
from model_mommy import mommy
from test.generic.models import has_pil
@@ -209,7 +209,7 @@ def test_filling_EmailField(self):
obj = mommy.make(DummyEmailModel)
field = DummyEmailModel._meta.get_field('email_field')
self.assertIsInstance(field, EmailField)
- self.assertIsInstance(obj.email_field, basestring)
+ self.assertIsInstance(obj.email_field, string_types)
class FillingGenericForeignKeyField(TestCase):
@@ -254,7 +254,7 @@ def test_filling_image_file_field(self):
self.assertIsInstance(field, ImageField)
import time
path = "%s/%s/mock-img.jpeg" % (gettempdir(), time.strftime('%Y/%m/%d'))
-
+
from django import VERSION
if VERSION[1] >= 4:
# These require the file to exist in earlier versions of Django
View
6 test/generic/tests/test_mommy.py
@@ -171,9 +171,9 @@ def test_prepare_should_not_create_one_object(self):
def test_create_one_to_one(self):
lonely_person = mommy.make(LonelyPerson)
- self.assertEquals(LonelyPerson.objects.all().count(), 1)
+ self.assertEqual(LonelyPerson.objects.all().count(), 1)
self.assertTrue(isinstance(lonely_person.only_friend, Person))
- self.assertEquals(Person.objects.all().count(), 1)
+ self.assertEqual(Person.objects.all().count(), 1)
def test_create_many_to_many_if_flagged(self):
store = mommy.make(Store, make_m2m=True)
@@ -262,7 +262,7 @@ def test_unsupported_model_raises_an_explanatory_exception(self):
try:
mommy.make(UnsupportedModel)
self.fail("Should have raised a TypeError")
- except TypeError, e:
+ except TypeError as e:
self.assertTrue('not supported' in repr(e))
View
3  test/generic/tests/test_recipes.py
@@ -281,7 +281,7 @@ def test_not_accept_other_type(self):
with self.assertRaises(TypeError) as c:
foreign_key(2)
exception = c.exception
- self.assertEqual(exception.message, 'Not a recipe')
+ self.assertEqual(str(exception), 'Not a recipe')
def test_do_not_create_related_model(self):
"""
@@ -391,4 +391,3 @@ def test_increment_by_3(self):
self.assertEqual(dummy.default_int_field, 19)
self.assertEqual(dummy.default_decimal_field, Decimal('27.3'))
self.assertAlmostEqual(dummy.default_float_field, 6.63)
-
View
32 tox.ini
@@ -1,7 +1,8 @@
[tox]
-envlist = django1.4, django1.4-timezone, django1.5, django1.5-timezone
+envlist = django1.4, django1.4-timezone, django1.5-py2, django1.5-py2-timezone, django1.5-py3, django1.5-py3-timezone
[testenv:django1.4]
+basepython = python2.7
deps =
django==1.4
Pillow==2.1.0
@@ -10,6 +11,7 @@ deps =
commands=./runtests.py
[testenv:django1.4-timezone]
+basepython = python2.7
deps =
django==1.4
Pillow==2.1.0
@@ -17,17 +19,37 @@ deps =
six==1.3.0
commands=./runtests.py --use-tz
-[testenv:django1.5]
+[testenv:django1.5-py2]
+basepython = python2.7
deps =
- django==1.5.1
+ django==1.5
Pillow==2.1.0
mock==1.0.1
six==1.3.0
commands=./runtests.py
-[testenv:django1.5-timezone]
+[testenv:django1.5-py2-timezone]
+basepython = python2.7
deps =
- django==1.5.1
+ django==1.5
+ Pillow==2.1.0
+ mock==1.0.1
+ six==1.3.0
+commands=./runtests.py --use-tz
+
+[testenv:django1.5-py3]
+basepython = python3.3
+deps =
+ django==1.5
+ Pillow==2.1.0
+ mock==1.0.1
+ six==1.3.0
+commands=./runtests.py
+
+[testenv:django1.5-py3-timezone]
+basepython = python3.3
+deps =
+ django==1.5
Pillow==2.1.0
mock==1.0.1
six==1.3.0
Please sign in to comment.
Something went wrong with that request. Please try again.