Browse files

renaming definitions from mockup to mockups, caused autodiscover to b…

…arf, fixed that
  • Loading branch information...
1 parent 66f0cd6 commit bccac6e27cfd1471dc8e3db52bad61a1a746b53a Mikko Hellsing committed Oct 16, 2010
Showing with 16 additions and 16 deletions.
  1. +6 −6 mockups/base.py
  2. +10 −10 mockups/helpers.py
View
12 mockups/base.py
@@ -98,7 +98,7 @@ class IGNORE_FIELD(object):
follow_m2m = {'ALL': (1,5)}
generate_m2m = False
- tries = 1000
+ creation_tries = 1000
field_to_generator = SortedDict((
(fields.BooleanField, generators.BooleanGenerator),
@@ -423,23 +423,23 @@ def create_one(self, commit=True):
May raise :exc:`CreateInstanceError` if constraints are not satisfied.
'''
- tries = self.tries
+ creation_tries = self.creation_tries
instance = self.model()
process = instance._meta.fields
- while process and tries > 0:
+ while process and creation_tries > 0:
for field in process:
self.process_field(instance, field)
process = self.check_constrains(instance)
- tries -= 1
- if tries == 0:
+ creation_tries -= 1
+ if creation_tries == 0:
raise CreateInstanceError(
u'Cannot solve constraints for "%s", tried %d times. '
u'Please check value generators or model constraints. '
u'At least the following fields are involved: %s' % (
'%s.%s' % (
self.model._meta.app_label,
self.model._meta.object_name),
- self.tries,
+ self.creation_tries,
', '.join([field.name for field in process]),
))
if commit:
View
20 mockups/helpers.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
import copy
+import imp
import warnings
from django.conf import settings
from django.utils.importlib import import_module
-from django.utils.module_loading import module_has_submodule
__all__ = ('register', 'unregister', 'create', 'create_one', 'autodiscover')
@@ -130,17 +130,17 @@ def autodiscover():
for app in settings.INSTALLED_APPS:
mod = import_module(app)
- # Attempt to import the app's mockup module.
+ # Attempt to import the app's mockups module.
try:
before_import_registry = copy.copy(_registry)
- import_module('%s.mockup' % app)
- except Exception:
+ import_module('%s.mockups' % app)
+ except Exception, e:
# Reset the model registry to the state before the last import
_registry = before_import_registry
-
- # Decide whether to bubble up this error. If the app just
- # doesn't have an mockup module, we can ignore the error
- # attempting to import it, otherwise we want it to bubble up.
- if module_has_submodule(mod, 'mockup'):
- raise
+ # If the module is not there, do not raise exception
+ try:
+ imp.find_module('mockups', mod.__path__)
+ except (AttributeError, ImportError):
+ continue
+ raise e

0 comments on commit bccac6e

Please sign in to comment.