[Python-modules-commits] [python-model-mommy] 01/02: Import python-model-mommy_1.3.2.orig.tar.gz

Edward Betts edward at moszumanska.debian.org
Wed May 3 15:42:05 UTC 2017


This is an automated email from the git hooks/post-receive script.

edward pushed a commit to branch master
in repository python-model-mommy.

commit 22097f16331317bcf6761adc8afdaa95cc48b916
Author: Edward Betts <edward at 4angle.com>
Date:   Fri Apr 21 13:55:11 2017 +0100

    Import python-model-mommy_1.3.2.orig.tar.gz
---
 PKG-INFO                         |  2 +-
 model_mommy.egg-info/PKG-INFO    |  2 +-
 model_mommy.egg-info/SOURCES.txt |  1 +
 model_mommy/__init__.py          |  2 +-
 model_mommy/generators.py        |  7 +++++++
 model_mommy/random_gen.py        |  3 +++
 model_mommy/recipe.py            | 11 ++++++++---
 setup.cfg                        |  4 +++-
 tox.ini                          |  3 ++-
 9 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index c3e844f..c0e6fa9 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: model_mommy
-Version: 1.3.1
+Version: 1.3.2
 Summary: Smart object creation facility for Django.
 Home-page: http://github.com/vandersonmota/model_mommy
 Author: vandersonmota
diff --git a/model_mommy.egg-info/PKG-INFO b/model_mommy.egg-info/PKG-INFO
index e384673..3583b84 100644
--- a/model_mommy.egg-info/PKG-INFO
+++ b/model_mommy.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: model-mommy
-Version: 1.3.1
+Version: 1.3.2
 Summary: Smart object creation facility for Django.
 Home-page: http://github.com/vandersonmota/model_mommy
 Author: vandersonmota
diff --git a/model_mommy.egg-info/SOURCES.txt b/model_mommy.egg-info/SOURCES.txt
index bb2db79..bab3cea 100644
--- a/model_mommy.egg-info/SOURCES.txt
+++ b/model_mommy.egg-info/SOURCES.txt
@@ -1,6 +1,7 @@
 MANIFEST.in
 README.rst
 requirements.txt
+setup.cfg
 setup.py
 tox.ini
 model_mommy/__init__.py
diff --git a/model_mommy/__init__.py b/model_mommy/__init__.py
index 73b3d5a..2d9550f 100644
--- a/model_mommy/__init__.py
+++ b/model_mommy/__init__.py
@@ -1,5 +1,5 @@
 #coding:utf-8
-__version__ = '1.3.1'
+__version__ = '1.3.2'
 __title__ = 'model_mommy'
 __author__ = 'Vanderson Mota'
 __license__ = 'Apache 2.0'
diff --git a/model_mommy/generators.py b/model_mommy/generators.py
index 30b28b5..095246b 100644
--- a/model_mommy/generators.py
+++ b/model_mommy/generators.py
@@ -44,6 +44,11 @@ try:
 except ImportError:
     JSONField = None
 
+try:
+    from django.contrib.postgres.fields import HStoreField
+except ImportError:
+    HStoreField = None
+
 from . import random_gen
 default_mapping = {
     ForeignKey: random_gen.gen_related,
@@ -89,6 +94,8 @@ if ArrayField:
     default_mapping[ArrayField] = random_gen.gen_array
 if JSONField:
     default_mapping[JSONField] = random_gen.gen_json
+if HStoreField:
+    default_mapping[HStoreField] = random_gen.gen_hstore
 
 
 def get_type_mapping():
diff --git a/model_mommy/random_gen.py b/model_mommy/random_gen.py
index 8676c19..6cb7c0a 100644
--- a/model_mommy/random_gen.py
+++ b/model_mommy/random_gen.py
@@ -213,6 +213,9 @@ def gen_json():
     return {}
 
 
+def gen_hstore():
+    return {}
+
 def _fk_model(field):
     try:
         return ('model', field.related_model)
diff --git a/model_mommy/recipe.py b/model_mommy/recipe.py
index c709ea6..5bf5d74 100644
--- a/model_mommy/recipe.py
+++ b/model_mommy/recipe.py
@@ -32,6 +32,7 @@ class Recipe(object):
         self._iterator_backups = {}
 
     def _mapping(self, new_attrs):
+        _save_related = new_attrs.get('_save_related', True)
         rel_fields_attrs = dict((k, v) for k, v in new_attrs.items() if '__' in k)
         new_attrs = dict((k, v) for k, v in new_attrs.items() if not '__' in k)
         mapping = self.attr_mapping.copy()
@@ -53,7 +54,10 @@ class Recipe(object):
                     if key.startswith('%s__' % k):
                         a[key] = rel_fields_attrs.pop(key)
                 recipe_attrs = mommy.filter_rel_attrs(k, **a)
-                mapping[k] = v.recipe.make(**recipe_attrs)
+                if _save_related:
+                    mapping[k] = v.recipe.make(**recipe_attrs)
+                else:
+                    mapping[k] = v.recipe.prepare(**recipe_attrs)
             elif isinstance(v, related):
                 mapping[k] = v.make()
         mapping.update(new_attrs)
@@ -64,7 +68,9 @@ class Recipe(object):
         return mommy.make(self.model, **self._mapping(attrs))
 
     def prepare(self, **attrs):
-        return mommy.prepare(self.model, **self._mapping(attrs))
+        defaults = {'_save_related': False}
+        defaults.update(attrs)
+        return mommy.prepare(self.model, **self._mapping(defaults))
 
     def extend(self, **attrs):
         attr_mapping = self.attr_mapping.copy()
@@ -156,4 +162,3 @@ class related(object):
          Persists objects to m2m relation
         """
         return [m.make() for m in self.related]
-
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..adf5ed7 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,7 @@
+[bdist_wheel]
+universal = 1
+
 [egg_info]
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0
 
diff --git a/tox.ini b/tox.ini
index f99b776..7405d71 100644
--- a/tox.ini
+++ b/tox.ini
@@ -10,7 +10,8 @@ basepython =
     py35: python3.5
     py34: python3.4
 deps =
-    Pillow>=2.3.1
+    py26: Pillow>=2.3.1,<4.0.0
+    py{27,34,35}: Pillow>=2.3.1
     mock==1.0.1
     six>=1.3.0
     django-test-without-migrations

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-model-mommy.git



More information about the Python-modules-commits mailing list