Exemplo n.º 1
0
    def setUp(self):
        self.old_staticfiles_url = settings.STATICFILES_URL
        self.old_staticfiles_root = settings.STATICFILES_ROOT
        self.old_staticfiles_dirs = settings.STATICFILES_DIRS
        self.old_staticfiles_finders = settings.STATICFILES_FINDERS
        self.old_installed_apps = settings.INSTALLED_APPS
        self.old_media_root = settings.MEDIA_ROOT
        self.old_media_url = settings.MEDIA_URL
        self.old_admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
        self.old_debug = settings.DEBUG

        # We have to load these apps to test staticfiles.
        load_app('regressiontests.staticfiles_tests.apps.test')
        load_app('regressiontests.staticfiles_tests.apps.no_label')
        site_media = os.path.join(TEST_ROOT, 'project', 'site_media')
        settings.DEBUG = True
        settings.MEDIA_ROOT =  os.path.join(site_media, 'media')
        settings.MEDIA_URL = '/media/'
        settings.STATICFILES_ROOT = os.path.join(site_media, 'static')
        settings.STATICFILES_URL = '/static/'
        settings.ADMIN_MEDIA_PREFIX = '/static/admin/'
        settings.STATICFILES_DIRS = (
            os.path.join(TEST_ROOT, 'project', 'documents'),
        )
        settings.STATICFILES_FINDERS = (
            'django.contrib.staticfiles.finders.FileSystemFinder',
            'django.contrib.staticfiles.finders.AppDirectoriesFinder',
            'django.contrib.staticfiles.finders.DefaultStorageFinder',
        )
Exemplo n.º 2
0
 def setUp(self):
     # Trick to be able to use test templates (inspired from django.contrib.auth.tests.views.ChangePasswordTest)
     self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
     settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__),'templates'),)
     
     # Trick to dynamically install a test-specific app (until ticket #7835 get checked in: http://code.djangoproject.com/ticket/7835)
     self.old_INSTALLED_APPS = settings.INSTALLED_APPS
     settings.INSTALLED_APPS = (       
         'imageutil',
         'imageutil.tests.testapp',
     )
     load_app('imageutil.tests.testapp')
     call_command('flush', verbosity=0, interactive=False)
     call_command('syncdb', verbosity=0, interactive=False)
     
     # since django's r11862 templatags_modules and app_template_dirs are cached
     # the cache is not emptied between tests
     # clear out the cache of modules to load templatetags from so it gets refreshed
     template.templatetags_modules = []
     
     # clear out the cache of app_directories to load templates from so it gets refreshed
     app_directories.app_template_dirs = []
     # reload the module to refresh the cache
     reload(app_directories)
     
     # Load test fixtures
     self.old_FIXTURE_DIRS = settings.FIXTURE_DIRS
     settings.FIXTURE_DIRS = (os.path.join(os.path.dirname(__file__), 'fixtures'),)
     call_command('loaddata', 'iwh.json', verbosity=0, interactive=False)
Exemplo n.º 3
0
def include_enabled_extensions(settings):
    """
    This adds enabled extensions to the INSTALLED_APPS cache
    so that operations like syncdb and evolve will take extensions
    into consideration.
    """
    # Some of our checks require access to django.conf.settings, so
    # tell Django about our settings.
    #
    # This must go before the imports.
    setup_environ(settings)

    from django.db.models.loading import load_app
    from django.db import DatabaseError

    from reviewboard.extensions.base import get_extension_manager

    try:
        manager = get_extension_manager()
        manager.load()
    except DatabaseError:
        # This database is from a time before extensions, so don't attempt to
        # load any extensions yet.
        return

    for extension in manager.get_enabled_extensions():
        load_app(extension.info.app_name)
Exemplo n.º 4
0
def include_enabled_extensions(settings):
    """
    This adds enabled extensions to the INSTALLED_APPS cache
    so that operations like syncdb and evolve will take extensions
    into consideration.
    """
    # Some of our checks require access to django.conf.settings, so
    # tell Django about our settings.
    #
    # This must go before the imports.
    setup_environ(settings)

    from django.db.models.loading import load_app
    from django.db import DatabaseError

    from reviewboard.extensions.base import get_extension_manager

    try:
        manager = get_extension_manager()
        manager.load()
    except DatabaseError:
        # This database is from a time before extensions, so don't attempt to
        # load any extensions yet.
        return

    for extension in manager.get_enabled_extensions():
        load_app(extension.info.app_name)
Exemplo n.º 5
0
    def setUp(self):
        super(TestModelsLoaderMixin, self).setUp()

        # If we made a fake 'models' module, add it to sys.modules.
        models_mod = self._tests_loader_models_mod

        if models_mod:
            sys.modules[models_mod.__name__] = models_mod

        self._models_loader_old_settings = settings.INSTALLED_APPS
        settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + [
            self.tests_app,
        ]

        if apps:
            # Push the new set of installed apps, and begin registering
            # each of the models associated with the tests.
            apps.set_installed_apps(settings.INSTALLED_APPS)
            app_config = apps.get_containing_app_config(self.tests_app)

            for key, value in six.iteritems(models_mod.__dict__):
                if inspect.isclass(value) and issubclass(value, Model):
                    apps.register_model(app_config.label, value)

            call_command('migrate', verbosity=0, interactive=False)
        else:
            load_app(self.tests_app)
            call_command('syncdb', verbosity=0, interactive=False)
Exemplo n.º 6
0
    def setUp(self):
        super(TestModelsLoaderMixin, self).setUp()

        # If we made a fake 'models' module, add it to sys.modules.
        models_mod = self._tests_loader_models_mod

        if models_mod:
            sys.modules[models_mod.__name__] = models_mod

        self._models_loader_old_settings = settings.INSTALLED_APPS
        settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + [
            self.tests_app,
        ]

        if apps:
            # Push the new set of installed apps, and begin registering
            # each of the models associated with the tests.
            apps.set_installed_apps(settings.INSTALLED_APPS)
            app_config = apps.get_containing_app_config(self.tests_app)

            if models_mod:
                for key, value in six.iteritems(models_mod.__dict__):
                    if inspect.isclass(value) and issubclass(value, Model):
                        apps.register_model(app_config.label, value)

            call_command('migrate', verbosity=0, interactive=False)
        else:
            load_app(self.tests_app)
            call_command('syncdb', verbosity=0, interactive=False)
Exemplo n.º 7
0
    def setUp(self):
        # Install testapp
        self.old_INSTALLED_APPS = settings.INSTALLED_APPS
        settings.INSTALLED_APPS += ['holdingpage.tests.testapp']
        load_app('testapp')
        call_command('flush', verbosity=0, interactive=False)
        call_command('syncdb', verbosity=0, interactive=False)
        
        # Tweak settings
        if hasattr(settings, 'HOLDINGPAGE_ACTIVATED'):
            self.old_HOLDINGPAGE_ACTIVATED = settings.HOLDINGPAGE_ACTIVATED

        if 'holdingpage.middleware.HoldingPageMiddleware' not in settings.MIDDLEWARE_CLASSES:
            self.old_MIDDLEWARE_CLASSES = settings.MIDDLEWARE_CLASSES
            settings.MIDDLEWARE_CLASSES = list(settings.MIDDLEWARE_CLASSES) + ['holdingpage.middleware.HoldingPageMiddleware']
    
        if hasattr(settings, 'HOLDINGPAGE_ALLOWED_URL_PATTERNS'):
            self.old_HOLDINGPAGE_ALLOWED_URL_PATTERNS = settings.HOLDINGPAGE_ALLOWED_URL_PATTERNS
        settings.HOLDINGPAGE_ALLOWED_URL_PATTERNS = ['^/a_path/$']
        
        if hasattr(settings, 'HOLDINGPAGE_ALLOWED_VIEWS'):
            self.old_HOLDINGPAGE_ALLOWED_VIEWS = settings.HOLDINGPAGE_ALLOWED_VIEWS
        settings.HOLDINGPAGE_ALLOWED_VIEWS = ['holdingpage.tests.testapp.views.a_view']
    
        if hasattr(settings, 'HOLDINGPAGE_URL'):
            self.HOLDINGPAGE_URL = settings.HOLDINGPAGE_URL
        settings.HOLDINGPAGE_URL = '/holding-test/'
    
        # Initial Data
        self.notstaff_user = User.objects.create_user(username='******', email='*****@*****.**', password='******')
        self.staff_user = User.objects.create_user(username='******', email='*****@*****.**', password='******')
        self.staff_user.is_staff = True
        self.staff_user.save()
Exemplo n.º 8
0
 def setUp(self):
     self.old_INSTALLED_APPS = settings.INSTALLED_APPS
     settings.INSTALLED_APPS += ('workflow.tests.fakeapp', )
     load_app('workflow.tests.fakeapp')
     loading.cache.loaded = False
     call_command('syncdb', verbosity=0,
                  interactive=False)  #Create tables for fakeapp
 def setUp(self):
     print ">", settings.INSTALLED_APPS
     self.old_INSTALLED_APPS = settings.INSTALLED_APPS
     settings.INSTALLED_APPS += ( 'utils.tests.fakeapp', )
     loading.cache.loaded = False
     load_app('utils.tests.fakeapp')
     call_command('syncdb', verbosity=0, interactive=False) # Create tables for fakeapp
Exemplo n.º 10
0
    def setUp(self):
        self.__class__.__module__ = self.__class__.__name__

        self.old_INSTALLED_APPS = settings.INSTALLED_APPS
        settings.INSTALLED_APPS += [APP_NAME]
        load_app(APP_NAME)
        call_command('flush', verbosity=0, interactive=False)
        call_command('syncdb', verbosity=0, interactive=False)
    def setUp(self):
        self.__class__.__module__ = self.__class__.__name__

        self.old_INSTALLED_APPS = settings.INSTALLED_APPS
        settings.INSTALLED_APPS += [APP_NAME]
        load_app(APP_NAME)
        call_command('flush', verbosity=0, interactive=False)
        call_command('syncdb', verbosity=0, interactive=False)
Exemplo n.º 12
0
    def _setUp_test_app(self):
        app_name = 'method_cache.tests.mcthings'

        self.old_INSTALLED_APPS = settings.INSTALLED_APPS
        settings.INSTALLED_APPS = settings.INSTALLED_APPS + [app_name]

        load_app(app_name)
        call_command('syncdb', verbosity=0, interactive=False)
Exemplo n.º 13
0
 def _setUp_test_app(self):
     app_name = 'method_cache.tests.mcthings'
     
     self.old_INSTALLED_APPS = settings.INSTALLED_APPS 
     settings.INSTALLED_APPS = settings.INSTALLED_APPS + [app_name]
     
     load_app(app_name)
     call_command('syncdb', verbosity=0, interactive=False)
Exemplo n.º 14
0
 def setUp(self):
     self.old_INSTALLED_APPS = settings.INSTALLED_APPS
     settings.INSTALLED_APPS = (
         'usertools',
         'usertools.tests.test_app',
     )
     load_app('usertools.tests.test_app')
     call_command('syncdb', verbosity=0, interactive=False)
def install():
    import os, sys
    current_folder = os.path.dirname(__file__)
    sys.path.append(os.path.join(current_folder, 'libs'))
    from django.conf import settings
    settings.INSTALLED_APPS += ('cartoview.apps.cartoview_arcgis_feature_server.cartoserver',)
    from django.db.models.loading import load_app
    load_app('cartoview.apps.cartoview_arcgis_feature_server.cartoserver')
def install():
    import os, sys
    current_folder = os.path.dirname(__file__)
    sys.path.append(os.path.join(current_folder, 'libs'))
    from django.conf import settings
    settings.INSTALLED_APPS += (
        'cartoview.apps.cartoview_arcgis_feature_server.cartoserver', )
    from django.db.models.loading import load_app
    load_app('cartoview.apps.cartoview_arcgis_feature_server.cartoserver')
Exemplo n.º 17
0
 def setUp(self):
     self.old_INSTALLED_APPS = settings.INSTALLED_APPS
     settings.INSTALLED_APPS = (tuple(settings.INSTALLED_APPS) +
                                self.test_apps)
     for app in self.test_apps:
         load_app(app)
     if self.test_apps:
         # Create tables for any test-only applications.
         call_command('syncdb', verbosity=0, interactive=False)
Exemplo n.º 18
0
def add_test_apps(test_apps):
    from django.db.models.loading import load_app
    from django.core.management import call_command
    original_INSTALLED_APPS = settings.INSTALLED_APPS
    settings.INSTALLED_APPS = tuple(settings.INSTALLED_APPS) + tuple(test_apps)
    for test_app in test_apps:
        load_app(test_app)
    call_command('syncdb', verbosity=0, interactive=False)
    return original_INSTALLED_APPS
Exemplo n.º 19
0
 def setUp(self):
     self.maxDiff = None
     print ">>", settings.INSTALLED_APPS
     self.old_INSTALLED_APPS = settings.INSTALLED_APPS
     settings.INSTALLED_APPS += ('utils.tests.fakeapp', )
     loading.cache.loaded = False
     load_app('utils.tests.fakeapp')
     call_command('syncdb', verbosity=0,
                  interactive=False)  # Create tables for fakeapp
Exemplo n.º 20
0
  def post_environ(self):
    '''
    Call this method once django environ has been setup. This will tell the 
    plugins it's time to complete with the setup process.
    '''
    from django.db.models.loading import load_app
    for plugin in self.get_plugins():
      if plugin.provides.get('post_environ', False):
	plugin.module.post_environ()
    for plugin in self.get_plugins():
      load_app(plugin.name)
Exemplo n.º 21
0
Arquivo: tests.py Projeto: 10sr/hue
 def test_egg5(self):
     """Loading an app from an egg that has an import error in its models module raises that error"""
     egg_name = '%s/brokenapp.egg' % self.egg_dir
     sys.path.append(egg_name)
     self.assertRaises(ImportError, load_app, 'broken_app')
     try:
         load_app('broken_app')
     except ImportError as e:
         # Make sure the message is indicating the actual
         # problem in the broken app.
         self.assertTrue("modelz" in e.args[0])
Exemplo n.º 22
0
 def post_environ(self):
     '''
 Call this method once django environ has been setup. This will tell the 
 plugins it's time to complete with the setup process.
 '''
     from django.db.models.loading import load_app
     for plugin in self.get_plugins():
         if plugin.provides.get('post_environ', False):
             plugin.module.post_environ()
     for plugin in self.get_plugins():
         load_app(plugin.name)
Exemplo n.º 23
0
 def _pre_setup(self):
     self.saved_INSTALLED_APPS = settings.INSTALLED_APPS
     self.saved_DEBUG = settings.DEBUG
     test_app = 'suit.tests'
     settings.INSTALLED_APPS = tuple(
         list(self.saved_INSTALLED_APPS) + [test_app])
     settings.DEBUG = True
     # load our fake application and syncdb
     load_app(test_app)
     call_command('syncdb', verbosity=0, interactive=False)
     super(ModelsTestCaseMixin, self)._pre_setup()
Exemplo n.º 24
0
 def test_egg5(self):
     """Loading an app from an egg that has an import error in its models module raises that error"""
     egg_name = '%s/brokenapp.egg' % self.egg_dir
     sys.path.append(egg_name)
     self.assertRaises(ImportError, load_app, 'broken_app')
     try:
         load_app('broken_app')
     except ImportError, e:
         # Make sure the message is indicating the actual
         # problem in the broken app.
         self.assertTrue("modelz" in e.args[0])
Exemplo n.º 25
0
 def _pre_setup(self):
     self.saved_INSTALLED_APPS = settings.INSTALLED_APPS
     self.saved_DEBUG = settings.DEBUG
     test_app = 'suit.tests'
     settings.INSTALLED_APPS = tuple(
         list(self.saved_INSTALLED_APPS) + [test_app]
     )
     settings.DEBUG = True
     # load our fake application and syncdb
     load_app(test_app)
     call_command('syncdb', verbosity=0, interactive=False)
     super(ModelsTestCaseMixin, self)._pre_setup()
Exemplo n.º 26
0
 def _pre_setup(self):
     self.saved_INSTALLED_APPS = settings.INSTALLED_APPS
     self.saved_DEBUG = settings.DEBUG
     test_app = 'merge.tests.testapp'
     settings.INSTALLED_APPS = tuple(
         list(self.saved_INSTALLED_APPS) + [test_app]
     )
     settings.DEBUG = True
     # load our fake application and syncdb
     load_app(test_app)
     call_command('syncdb', verbosity=0, interactive=False)
     super(MergeSourceTests, self)._pre_setup()
Exemplo n.º 27
0
    def read(self, request):
        from django.db.models.loading import load_app

        errors = []
        for app in settings.INSTALLED_APPS:
            try:
                load_app(app)
            except Exception as e:
                errors.append({app: ("Can't load application {0}. Error was {1}").format(app, e)})
        if errors:
            return {"status": "error", "errors": errors}
        return {"status": "ok"}
Exemplo n.º 28
0
    def setUpClass(cls):
        # Modify sys path
        cls.old_sys_path = sys.path[:]
        sys.path.append(os.path.dirname(os.path.abspath(__file__)))

        # Change settings, we can't use decorator that would change settings too late for us.
        cls.override = override_settings(LANGUAGE_CODE='cs', LANGUAGES=TEST_LANGUAGES,
                                         INSTALLED_APPS=list(settings.INSTALLED_APPS) + ['ml_test_app'])
        cls.override.enable()
        # Install test app
        load_app('ml_test_app')
        call_command('syncdb', verbosity=0)
 def setUp(self):
     # Install testapp
     self.old_INSTALLED_APPS = settings.INSTALLED_APPS
     settings.INSTALLED_APPS += ['treemenus.tests.fake_menu_extension']
     load_app('fake_menu_extension')
     call_command('flush', verbosity=0, interactive=False)
     call_command('syncdb', verbosity=0, interactive=False)
     
     # Log in as admin
     User.objects.create_superuser('super', '*****@*****.**', 'secret')
     login = self.client.login(username='******', password='******')
     self.assertEqual(login, True)
    def handle_label(self, label, **options):
        platform_app = None

        logger = self._get_logger()

        logger.debug('attempting to import app: %s', label)

        try:
            load_app(label)
        except ImportError:
            logger.debug("could not import custom backend '%s'", label)
        else:
            platform_app = label

        if not platform_app:
            logger.debug('trying to import from parachute default apps')

            # import the correct app for the desired backend
            label = "%s.%s" % (self.import_app, label)
            try:
                load_app(label)
            except ImportError:
                logger.error("invalid import backend '%s' specified", label)
                return
            else:
                platform_app = label

        logger.info("succesfully loaded importer app for '%s'", platform_app)

        try:
            backend = __import__(platform_app, globals(), locals(), ['Importer'])
            importer = backend.Importer(
                app_name=label.split('.')[-1],
                force_update=options.get('force_update', False),
                verbosity=int(options.get('verbosity', logging.INFO)),
            )
        except AttributeError:
            logger.error("no importer available in backend '%s'", platform_app)
            return

        logger.debug("found importer object for '%s'", platform_app)

        importer.prepare_import(**options)

        if options.get('import_customers'):
            importer.import_customers()

        if options.get('import_catalogue'):
            importer.import_catalogue()

        if options.get('import_orders'):
            importer.import_orders()
Exemplo n.º 31
0
def _pre_setup(self):
    self.saved_INSTALLED_APPS = settings.INSTALLED_APPS
    self.saved_DEBUG = settings.DEBUG
    test_app = "johnny.tests.testapp"
    settings.INSTALLED_APPS = tuple(list(self.saved_INSTALLED_APPS) + [test_app])
    settings.DEBUG = True
    # load our fake application and syncdb
    load_app(test_app)
    call_command("syncdb", verbosity=0, interactive=False)
    if hasattr(settings, "DATABASES"):
        for dbname in settings.DATABASES:
            if dbname != "default":
                call_command("syncdb", verbosity=0, interactive=False, database=dbname)
Exemplo n.º 32
0
    def _pre_setup(self):
        #add BackupTestWidget model
        self.old_installed_apps = settings.INSTALLED_APPS
        settings.INSTALLED_APPS += ['vz_backup.tests.testwidgets']
        loading.cache.loaded = False
        loading.load_app('vz_backup.tests.testwidgets')
        call_command('syncdb', verbosity=0, interactive=False)

        #create a temp directory for backup archives
        self.old_backup_dir = settings.VZ_BACKUP_DIR
        settings.VZ_BACKUP_DIR = tempfile.mkdtemp()

        super(BackupTestCase, self)._pre_setup()
Exemplo n.º 33
0
def install_app(app_name):
    from django.conf import settings
    settings.INSTALLED_APPS.append ('apps.%s' % app_name)
    from django.db.models.loading import load_app
    load_app('apps.%s' % app_name)
    from django.core.management import call_command
    call_command('syncdb',load_initial_data=False)
    try:
        print os.path.join(APPS_DIR,app_name,'fixtures')
        call_command('loaddata', os.path.join(APPS_DIR,app_name,'fixtures','initial_data.json'))
    except Exception:
        pass
    from cartoview2.urls import register_app_urls
    register_app_urls(app_name)
Exemplo n.º 34
0
    def setUp(self):
        self.installed_apps = settings.INSTALLED_APPS
        settings.INSTALLED_APPS.append('cuddlybuddly.thumbnail.tests.cbtfakeapp')
        try:
            FakeImage.objects.count()
        except:
            load_app('cuddlybuddly.thumbnail.tests.cbtfakeapp')
            # Another try/except is needed because contrib.auth will sometimes
            # fail to create the permissions when some other third app is also
            # loaded.
            try:
                # Don't use call_command because if South is installed it
                # overrides syncdb and unnecessary warnings are printed out
                # during tests.
                from django.core.management.commands import syncdb
                syncdb.Command().handle_noargs(verbosity=0, interactive=False)
            except:
                pass

        self.images_to_delete = set()
        self.cache_to_delete = set()
        file = StringIO()
        Image.new('RGB', PIC_SIZE).save(file, 'JPEG')
        default_storage.save(PIC_NAME, ContentFile(file.getvalue()))
        self.images_to_delete.add(PIC_NAME)
        file.close()
        self.MEDIA_MIDDLE = os.path.join(
            getattr(settings, 'CUDDLYBUDDLY_THUMBNAIL_BASEDIR', ''),
            getattr(settings, 'CUDDLYBUDDLY_THUMBNAIL_SUBDIR', ''),
        )
        self.cache_backup = getattr(settings, 'CUDDLYBUDDLY_THUMBNAIL_CACHE', None)
        if not self.cache_backup:
            settings.CUDDLYBUDDLY_THUMBNAIL_CACHE = CACHE_DIR
        self.delete_cache_dir = False
        if self.cache_backup is None:
            if not os.path.exists(CACHE_DIR):
                self.delete_cache_dir = True
        cache = os.path.join(
            settings.CUDDLYBUDDLY_THUMBNAIL_CACHE,
            md5_constructor(smart_str(RELATIVE_PIC_NAME)).hexdigest()
        )
        self.cache_to_delete.add(cache)

        self.old_processors = thumbnail.PROCESSORS
        self.old_default_processor = thumbnail.DEFAULT_PROCESSOR
        thumbnail.PROCESSORS = {
            'crop': CropToFitProcessor,
            'resize': ResizeProcessor
        }
        thumbnail.DEFAULT_PROCESSOR = ResizeProcessor
Exemplo n.º 35
0
def _pre_setup(self):
    self.saved_INSTALLED_APPS = settings.INSTALLED_APPS
    self.saved_DEBUG = settings.DEBUG
    test_app = 'johnny.tests.testapp'
    settings.INSTALLED_APPS = tuple(
        list(self.saved_INSTALLED_APPS) + [test_app]
    )
    settings.DEBUG = True
    # load our fake application and syncdb
    load_app(test_app)
    call_command('syncdb', verbosity=0, interactive=False)
    if hasattr(settings, 'DATABASES'):
        for dbname in settings.DATABASES:
            if dbname != 'default':
                call_command('syncdb', verbosity=0, interactive=False, database=dbname)
Exemplo n.º 36
0
def install_app(app_name):
    from django.conf import settings
    settings.INSTALLED_APPS += (app_name,)
    from django.db.models.loading import load_app
    load_app(app_name)
    from django.core.management import call_command
    call_command('syncdb', load_initial_data=False)
    call_command('collectstatic', interactive=False)
    try:
        print os.path.join(settings.APPS_DIR, app_name, 'fixtures')
        call_command('loaddata', os.path.join(settings.APPS_DIR, app_name, 'fixtures', 'initial_data.json'))
    except Exception:
        pass
    # from urls import register_app_urls
    register_app_urls(app_name)
Exemplo n.º 37
0
    def prepareTestRunner(self, test):
        cur_stdout = sys.stdout
        cur_stderr = sys.stderr

        sys.stdout = self.sys_stdout
        sys.stderr = self.sys_stderr

        if self.add_apps:
            for app in self.add_apps:
                if app in settings.INSTALLED_APPS:
                    continue
                mod = load_app(app)
                if mod:
                    settings.INSTALLED_APPS.append(app)

        get_apps()

        self.runner.setup_test_environment()

        if self.needs_db:
            self.old_names = self.runner.setup_databases()

        sys.stdout = cur_stdout
        sys.stderr = cur_stderr

        self.started = True
Exemplo n.º 38
0
def setup(verbosity, test_labels):
    from django.conf import settings
    state = {
        'INSTALLED_APPS': settings.INSTALLED_APPS,
        'ROOT_URLCONF': getattr(settings, "ROOT_URLCONF", ""),
        'TEMPLATE_DIRS': settings.TEMPLATE_DIRS,
        'USE_I18N': settings.USE_I18N,
        'LOGIN_URL': settings.LOGIN_URL,
        'LANGUAGE_CODE': settings.LANGUAGE_CODE,
        'MIDDLEWARE_CLASSES': settings.MIDDLEWARE_CLASSES,
        'STATIC_URL': settings.STATIC_URL,
        'STATIC_ROOT': settings.STATIC_ROOT,
    }

    # Redirect some settings for the duration of these tests.
    settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS
    settings.ROOT_URLCONF = 'urls'
    settings.STATIC_URL = '/static/'
    settings.STATIC_ROOT = os.path.join(TEMP_DIR, 'static')
    settings.TEMPLATE_DIRS = (os.path.join(RUNTESTS_DIR, TEST_TEMPLATE_DIR), )
    settings.USE_I18N = True
    settings.LANGUAGE_CODE = 'en'
    settings.MIDDLEWARE_CLASSES = (
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.common.CommonMiddleware',
    )
    settings.SITE_ID = 1
    # For testing comment-utils, we require the MANAGERS attribute
    # to be set, so that a test email is sent out which we catch
    # in our tests.
    settings.MANAGERS = ("*****@*****.**", )

    # Load all the ALWAYS_INSTALLED_APPS.
    # (This import statement is intentionally delayed until after we
    # access settings because of the USE_I18N dependency.)

    django.setup()
    from django.db.models.loading import get_apps, load_app
    get_apps()

    # Load all the test model apps.
    test_labels_set = set([label.split('.')[0] for label in test_labels])
    test_modules = get_test_modules()

    for module_name in test_modules:
        module_label = module_name
        # if the module was named on the command line, or
        # no modules were named (i.e., run all), import
        # this module and add it to the list to test.
        if not test_labels or module_name in test_labels_set:
            if verbosity >= 2:
                print "Importing application %s" % module_name
            mod = load_app(module_label)
            if mod:
                if module_label not in settings.INSTALLED_APPS:
                    settings.INSTALLED_APPS.append(module_label)

    return state
    def create_models_from_app(cls, app_name):
        """
        Manually create Models (used only for testing) from the specified string app name.
        Models are loaded from the module '<app_name>.models'
        """
        from django.db import connection, DatabaseError
        from django.test.simple import DjangoTestSuiteRunner

        # NB: `load_app` is deprecated as of Django 1.7.
        if re.match(r'''^1\.7.*$''', django.get_version()) is not None:
            from django.apps import apps
            # NB: Django 1.7 doesn't work with the fully-qualified app name.
            app = apps.get_app_config(app_name.split('.')[1])
        else:
            from django.db.models.loading import load_app
            app = load_app(app_name)

        from django.core.management import sql
        from django.core.management.color import no_style
        sql = sql.sql_create(app, no_style(), connection)
        cursor = connection.cursor()
        for statement in sql:
            try:
                cursor.execute(statement)
            except DatabaseError, excn:
                logger.debug(excn.message)
Exemplo n.º 40
0
    def setUp(self):
        super(TestModelsLoaderMixin, self).setUp()

        # If we made a fake 'models' module, add it to sys.modules.
        models_mod = self._tests_loader_models_mod

        if models_mod:
            sys.modules[models_mod.__name__] = models_mod

        self._models_loader_old_settings = settings.INSTALLED_APPS
        settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + [
            self.tests_app,
        ]

        load_app(self.tests_app)
        call_command('syncdb', verbosity=0, interactive=False)
Exemplo n.º 41
0
def setup(verbosity, test_labels):
    from django.conf import settings
    state = {
        'INSTALLED_APPS': settings.INSTALLED_APPS,
        'ROOT_URLCONF': getattr(settings, "ROOT_URLCONF", ""),
        'TEMPLATE_DIRS': settings.TEMPLATE_DIRS,
        'USE_I18N': settings.USE_I18N,
        'LOGIN_URL': settings.LOGIN_URL,
        'LANGUAGE_CODE': settings.LANGUAGE_CODE,
        'MIDDLEWARE_CLASSES': settings.MIDDLEWARE_CLASSES,
        'STATIC_URL': settings.STATIC_URL,
        'STATIC_ROOT': settings.STATIC_ROOT,
    }

    # Redirect some settings for the duration of these tests.
    settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS
    settings.ROOT_URLCONF = 'urls'
    settings.STATIC_URL = '/static/'
    settings.STATIC_ROOT = os.path.join(TEMP_DIR, 'static')
    settings.TEMPLATE_DIRS = (os.path.join(RUNTESTS_DIR, TEST_TEMPLATE_DIR),)
    settings.USE_I18N = True
    settings.LANGUAGE_CODE = 'en'
    settings.MIDDLEWARE_CLASSES = (
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.common.CommonMiddleware',
    )
    settings.SITE_ID = 1
    # For testing comment-utils, we require the MANAGERS attribute
    # to be set, so that a test email is sent out which we catch
    # in our tests.
    settings.MANAGERS = ("*****@*****.**",)

    # Load all the ALWAYS_INSTALLED_APPS.
    # (This import statement is intentionally delayed until after we
    # access settings because of the USE_I18N dependency.)

    django.setup()
    from django.db.models.loading import get_apps, load_app
    get_apps()

    # Load all the test model apps.
    test_labels_set = set([label.split('.')[0] for label in test_labels])
    test_modules = get_test_modules()

    for module_name in test_modules:
        module_label = module_name
        # if the module was named on the command line, or
        # no modules were named (i.e., run all), import
        # this module and add it to the list to test.
        if not test_labels or module_name in test_labels_set:
            if verbosity >= 2:
                print "Importing application %s" % module_name
            mod = load_app(module_label)
            if mod:
                if module_label not in settings.INSTALLED_APPS:
                    settings.INSTALLED_APPS.append(module_label)

    return state
Exemplo n.º 42
0
def django_tests(verbosity, interactive, failfast, test_labels):
    from django.conf import settings

    old_installed_apps = settings.INSTALLED_APPS
    old_root_urlconf = getattr(settings, "ROOT_URLCONF", "")
    old_template_dirs = settings.TEMPLATE_DIRS
    old_use_i18n = settings.USE_I18N
    old_login_url = settings.LOGIN_URL
    old_language_code = settings.LANGUAGE_CODE
    old_middleware_classes = settings.MIDDLEWARE_CLASSES

    # Load all the ALWAYS_INSTALLED_APPS.
    # (This import statement is intentionally delayed until after we
    # access settings because of the USE_I18N dependency.)
    from django.db.models.loading import get_apps, load_app
    get_apps()

    # Load all the test model apps.
    for model_dir, model_name in get_test_models():
        model_label = '.'.join([model_dir, model_name])
        try:
            # if the model was named on the command line, or
            # no models were named (i.e., run all), import
            # this model and add it to the list to test.
            if not test_labels or model_name in set([label.split('.')[0] for label in test_labels]):
                if verbosity >= 1:
                    print "Importing model %s" % model_name
                mod = load_app(model_label)
                if mod:
                    if model_label not in settings.INSTALLED_APPS:
                        settings.INSTALLED_APPS.append(model_label)
        except Exception, e:
            sys.stderr.write("Error while importing %s:" % model_name + ''.join(traceback.format_exception(*sys.exc_info())[1:]))
            continue
Exemplo n.º 43
0
    def prepareTestRunner(self, test):
        cur_stdout = sys.stdout
        cur_stderr = sys.stderr

        sys.stdout = self.sys_stdout
        sys.stderr = self.sys_stderr

        if self.add_apps:
            for app in self.add_apps:
                if app in settings.INSTALLED_APPS:
                    continue
                mod = load_app(app)
                if mod:
                    settings.INSTALLED_APPS.append(app)

        get_apps()

        self.runner.setup_test_environment()

        if self.needs_db:
            self.old_names = self.runner.setup_databases()

        sys.stdout = cur_stdout
        sys.stderr = cur_stderr

        self.started = True
Exemplo n.º 44
0
    def runTest(self):
        from django.core.management.validation import get_validation_errors
        from django.db.models.loading import load_app
        from io import StringIO

        try:
            module = load_app(self.model_label)
        except Exception as e:
            self.fail('Unable to load invalid model module')

        # Make sure sys.stdout is not a tty so that we get errors without
        # coloring attached (makes matching the results easier). We restore
        # sys.stderr afterwards.
        orig_stdout = sys.stdout
        s = StringIO()
        sys.stdout = s
        count = get_validation_errors(s, module)
        sys.stdout = orig_stdout
        s.seek(0)
        error_log = s.read()
        actual = error_log.split('\n')
        expected = module.model_errors.split('\n')

        unexpected = [err for err in actual if err not in expected]
        missing = [err for err in expected if err not in actual]

        self.assertTrue(not unexpected, "Unexpected Errors: " + '\n'.join(unexpected))
        self.assertTrue(not missing, "Missing Errors: " + '\n'.join(missing))
    def create_models_from_app(cls, app_name):
        """
        Manually create Models (used only for testing) from the specified string app name.
        Models are loaded from the module '<app_name>.models'
        """
        from django.db import connection, DatabaseError
        from django.test.simple import DjangoTestSuiteRunner

        # NB: `load_app` is deprecated as of Django 1.7.
        if re.match(r'''^1\.7.*$''', django.get_version()) is not None:
            from django.apps import apps
            # NB: Django 1.7 doesn't work with the fully-qualified app name.
            app = apps.get_app_config(app_name.split('.')[1])
        else:
            from django.db.models.loading import load_app
            app = load_app(app_name)

        from django.core.management import sql
        from django.core.management.color import no_style
        sql = sql.sql_create(app, no_style(), connection)
        cursor = connection.cursor()
        for statement in sql:
            try:
                cursor.execute(statement)
            except DatabaseError, excn:
                logger.debug(excn.message)
Exemplo n.º 46
0
def django_tests(verbosity, interactive, failfast, test_labels):
    from django.conf import settings

    old_installed_apps = settings.INSTALLED_APPS
    old_root_urlconf = getattr(settings, "ROOT_URLCONF", "")
    old_template_dirs = settings.TEMPLATE_DIRS
    old_use_i18n = settings.USE_I18N
    old_login_url = settings.LOGIN_URL
    old_language_code = settings.LANGUAGE_CODE
    old_middleware_classes = settings.MIDDLEWARE_CLASSES

    # Redirect some settings for the duration of these tests.
    settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS
    settings.ROOT_URLCONF = 'urls'
    settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__),
                                           TEST_TEMPLATE_DIR), )
    settings.USE_I18N = True
    settings.LANGUAGE_CODE = 'en'
    settings.LOGIN_URL = '/accounts/login/'
    settings.MIDDLEWARE_CLASSES = (
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.common.CommonMiddleware',
    )
    settings.SITE_ID = 1
    # For testing comment-utils, we require the MANAGERS attribute
    # to be set, so that a test email is sent out which we catch
    # in our tests.
    settings.MANAGERS = ("*****@*****.**", )

    # Load all the ALWAYS_INSTALLED_APPS.
    # (This import statement is intentionally delayed until after we
    # access settings because of the USE_I18N dependency.)
    from django.db.models.loading import get_apps, load_app
    get_apps()

    # Load all the test model apps.
    for model_dir, model_name in get_test_models():
        model_label = '.'.join([model_dir, model_name])
        try:
            # if the model was named on the command line, or
            # no models were named (i.e., run all), import
            # this model and add it to the list to test.
            if not test_labels or model_name in set(
                [label.split('.')[0] for label in test_labels]):
                if verbosity >= 1:
                    print "Importing model %s" % model_name
                mod = load_app(model_label)
                if mod:
                    if model_label not in settings.INSTALLED_APPS:
                        settings.INSTALLED_APPS.append(model_label)
        except Exception, e:
            sys.stderr.write(
                "Error while importing %s:" % model_name +
                ''.join(traceback.format_exception(*sys.exc_info())[1:]))
            continue
Exemplo n.º 47
0
    def runTest(self):
        from django.core.management.validation import get_validation_errors
        from django.db.models.loading import load_app
        from cStringIO import StringIO

        try:
            module = load_app(self.model_label)
        except Exception, e:
            self.fail('Unable to load invalid model module')
Exemplo n.º 48
0
def install_app(app_name):
    from django.conf import settings
    settings.INSTALLED_APPS += (app_name, )
    from django.db.models.loading import load_app
    load_app(app_name)
    from django.core.management import call_command
    call_command('syncdb', load_initial_data=False)
    call_command('collectstatic', interactive=False)
    try:
        print os.path.join(settings.APPS_DIR, app_name, 'fixtures')
        call_command(
            'loaddata',
            os.path.join(settings.APPS_DIR, app_name, 'fixtures',
                         'initial_data.json'))
    except Exception:
        pass
    # from urls import register_app_urls
    register_app_urls(app_name)
Exemplo n.º 49
0
    def setUp(self):
        super(TestModelsLoaderMixin, self).setUp()

        # If we made a fake 'models' module, add it to sys.modules.
        models_mod = self._tests_loader_models_mod

        if models_mod:
            sys.modules[models_mod.__name__] = models_mod

        self._models_loader_old_settings = settings.INSTALLED_APPS
        settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + [
            self.tests_app,
        ]

        if apps:
            # Push the new set of installed apps, and begin registering
            # each of the models associated with the tests.
            apps.set_installed_apps(settings.INSTALLED_APPS)
            app_config = apps.get_containing_app_config(self.tests_app)

            if models_mod:
                app_label = app_config.label

                for key, value in six.iteritems(models_mod.__dict__):
                    if inspect.isclass(value) and issubclass(value, Model):
                        # The model was likely registered under another app,
                        # so we need to remove the old one and add the new
                        # one.
                        try:
                            del apps.all_models[value._meta.app_label][
                                value._meta.model_name]
                        except KeyError:
                            pass

                        value._meta.app_label = app_label
                        apps.register_model(app_label, value)

            call_command('migrate',
                         run_syncdb=True,
                         verbosity=0,
                         interactive=False)
        else:
            load_app(self.tests_app)
            call_command('syncdb', verbosity=0, interactive=False)
Exemplo n.º 50
0
    def _pre_setup(self):
        self.saved_INSTALLED_APPS = settings.INSTALLED_APPS
        self.saved_DEBUG = settings.DEBUG
        test_app = 'suit.tests'
        settings.INSTALLED_APPS = tuple(
            list(self.saved_INSTALLED_APPS) + [test_app])
        settings.DEBUG = True

        # Legacy Django < 1.9: load our fake application and syncdb
        try:
            from django.db.models.loading import load_app
            load_app(test_app)
        except ImportError:
            pass
        try:
            call_command('syncdb', verbosity=0, interactive=False)
        except CommandError:
            pass
        super(ModelsTestCaseMixin, self)._pre_setup()
Exemplo n.º 51
0
def include_enabled_extensions(settings):
    """
    This adds enabled extensions to the INSTALLED_APPS cache
    so that operations like syncdb and evolve will take extensions
    into consideration.
    """
    from django.db.models.loading import load_app
    from django.db import DatabaseError

    from reviewboard.extensions.base import get_extension_manager

    try:
        manager = get_extension_manager()
    except DatabaseError:
        # This database is from a time before extensions, so don't attempt to
        # load any extensions yet.
        return

    for extension in manager.get_enabled_extensions():
        load_app(extension.info.app_name)
Exemplo n.º 52
0
def are_installed_models(app_name):
    if have_south(app_name):
        return False
    app_module = load_app(get_plugin_module_name(app_name))
    plugin_models = get_models(app_module)
    tables = connection.introspection.table_names()
    seen_models = connection.introspection.installed_models(tables)
    for plugin_model in plugin_models:
        if not plugin_model in seen_models:
            return False
    return True
Exemplo n.º 53
0
def django_tests(verbosity, interactive, test_labels):
    from django.conf import settings

    import deseb
    deseb.add_aka_support()

    old_installed_apps = settings.INSTALLED_APPS
    old_test_database_name = settings.TEST_DATABASE_NAME
    old_root_urlconf = settings.ROOT_URLCONF
    old_template_dirs = settings.TEMPLATE_DIRS
    old_use_i18n = settings.USE_I18N
    old_middleware_classes = settings.MIDDLEWARE_CLASSES

    # Redirect some settings for the duration of these tests.
    settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS
    settings.ROOT_URLCONF = 'urls'
    settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__),
                                           TEST_TEMPLATE_DIR), )
    settings.USE_I18N = True
    settings.MIDDLEWARE_CLASSES = (
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.middleware.common.CommonMiddleware',
    )
    if not hasattr(settings, 'SITE_ID'):
        settings.SITE_ID = 1

    # Load all the ALWAYS_INSTALLED_APPS.
    # (This import statement is intentionally delayed until after we
    # access settings because of the USE_I18N dependency.)
    from django.db.models.loading import get_apps, load_app
    get_apps()

    # Load all the test model apps.
    test_models = []
    for model_dir, model_name in get_test_models():
        model_label = '.'.join([model_dir, model_name])
        try:
            # if the model was named on the command line, or
            # no models were named (i.e., run all), import
            # this model and add it to the list to test.
            if not test_labels or model_name in set(
                [label.split('.')[0] for label in test_labels]):
                if verbosity >= 1:
                    print "Importing model %s" % model_name
                mod = load_app(model_label)
                if mod:
                    if model_label not in settings.INSTALLED_APPS:
                        settings.INSTALLED_APPS.append(model_label)
        except Exception, e:
            sys.stderr.write(
                "Error while importing %s:" % model_name +
                ''.join(traceback.format_exception(*sys.exc_info())[1:]))
            continue
Exemplo n.º 54
0
    def setUp(self):
        # Install testapp
        self.old_INSTALLED_APPS = settings.INSTALLED_APPS
        settings.INSTALLED_APPS += ['treemenus.tests.fake_menu_extension']
        load_app('treemenus.tests.fake_menu_extension')
        call_command('syncdb', verbosity=0, interactive=False)

        # since django's r11862 templatags_modules and app_template_dirs are cached
        # the cache is not emptied between tests
        # clear out the cache of modules to load templatetags from so it gets refreshed
        template.templatetags_modules = []

        # clear out the cache of app_directories to load templates from so it gets refreshed
        app_directories.app_template_dirs = []
        # reload the module to refresh the cache
        reload(app_directories)
        # Log in as admin
        User.objects.create_superuser('super', '*****@*****.**', 'secret')
        login = self.client.login(username='******', password='******')
        self.assertEqual(login, True)
Exemplo n.º 55
0
    def setUp(self):
        self.__class__.__module__ = self.__class__.__name__

        self.old_INSTALLED_APPS = settings.INSTALLED_APPS
        if isinstance(settings.INSTALLED_APPS, tuple):
            settings.INSTALLED_APPS += (APP_NAME, )
        else:
            settings.INSTALLED_APPS += [APP_NAME]
        self._old_root_urlconf = settings.ROOT_URLCONF
        settings.ROOT_URLCONF = '%s.urls' % APP_NAME
        load_app(APP_NAME)
        call_command('flush', verbosity=0, interactive=False)
        call_command('syncdb', verbosity=0, interactive=False)
        self.ae = self.assertEqual
        self._old_template_loaders = settings.TEMPLATE_LOADERS
        loaders = list(settings.TEMPLATE_LOADERS)
        try:
            loaders.remove('django.template.loaders.filesystem.Loader')
            settings.TEMPLATE_LOADERS = loaders
            self._refresh_cache()
        except ValueError:
            pass
Exemplo n.º 56
0
    def setUp(self):
        self.old_static_url = settings.STATIC_URL
        self.old_static_root = settings.STATIC_ROOT
        self.old_staticfiles_dirs = settings.STATICFILES_DIRS
        self.old_staticfiles_finders = settings.STATICFILES_FINDERS
        self.old_media_root = settings.MEDIA_ROOT
        self.old_media_url = settings.MEDIA_URL
        self.old_admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
        self.old_debug = settings.DEBUG
        self.old_installed_apps = settings.INSTALLED_APPS

        # We have to load these apps to test staticfiles.
        load_app('regressiontests.staticfiles_tests.apps.test')
        load_app('regressiontests.staticfiles_tests.apps.no_label')
        site_media = os.path.join(TEST_ROOT, 'project', 'site_media')
        settings.DEBUG = True
        settings.MEDIA_ROOT =  os.path.join(site_media, 'media')
        settings.MEDIA_URL = '/media/'
        settings.STATIC_ROOT = os.path.join(site_media, 'static')
        settings.STATIC_URL = '/static/'
        settings.ADMIN_MEDIA_PREFIX = '/static/admin/'
        settings.STATICFILES_DIRS = (
            os.path.join(TEST_ROOT, 'project', 'documents'),
        )
        settings.STATICFILES_FINDERS = (
            'django.contrib.staticfiles.finders.FileSystemFinder',
            'django.contrib.staticfiles.finders.AppDirectoriesFinder',
            'django.contrib.staticfiles.finders.DefaultStorageFinder',
        )
        settings.INSTALLED_APPS = [
            "django.contrib.staticfiles",
            "regressiontests.staticfiles_tests",
        ]

        # Clear the cached default_storage out, this is because when it first
        # gets accessed (by some other test), it evaluates settings.MEDIA_ROOT,
        # since we're planning on changing that we need to clear out the cache.
        default_storage._wrapped = None
Exemplo n.º 57
0
    def _create_test_models(cls, app_name='testapp'):
        """Create dynamic test models.

        Defaulted to models registered at app_name.models.py
        """

        app = loading.load_app(app_name)
        create_sql = sql.sql_create(app, color.no_style(), connection)
        cursor = connection.cursor()
        for statement in create_sql:
            try:
                cursor.execute(statement)
            except DatabaseError as ex:
                LOGGER.debug(ex)
Exemplo n.º 58
0
def add_fixtures(zip_config, plugin, plugin_path, plugin_path_zip):
    """
    Backup fixtures into zip file
    """
    from merengue.pluggable.utils import get_plugin_module_name
    # next two sentences is for avoiding problems with zipfile module
    # (encoding errors)
    plugin_path = smart_str(plugin_path)
    plugin_path_zip = smart_str(plugin_path_zip)
    plugin_modname = get_plugin_module_name(plugin.directory_name)
    plugin_mod = load_app(plugin_modname)
    plugin_models = get_models(plugin_mod)
    fixtures = get_fixtures(plugin_models)
    format = 'xml'
    fixtures_file = os.path.join(plugin_path_zip, "fixtures.%s" % format)
    zip_config.writestr(fixtures_file, "\n".join(fixtures))
Exemplo n.º 59
0
    def test_invalid_models(self):
        try:
            module = load_app("invalid_models.invalid_models")
        except Exception:
            self.fail('Unable to load invalid model module')

        get_validation_errors(self.stdout, module)
        self.stdout.seek(0)
        error_log = self.stdout.read()
        actual = error_log.split('\n')
        expected = module.model_errors.split('\n')

        unexpected = [err for err in actual if err not in expected]
        missing = [err for err in expected if err not in actual]
        self.assertFalse(unexpected, "Unexpected Errors: " + '\n'.join(unexpected))
        self.assertFalse(missing, "Missing Errors: " + '\n'.join(missing))