django.conf.settings.configure

Here are the examples of the python api django.conf.settings.configure taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

130 Examples 7

Example 1

Project: menagerie Source File: tests.py
    def test_overrides_global_settings(self):
        # Ensure that the global settings are used unless overriden.
        self.assertFalse(global_settings.DEBUG)  # sanity check
        settings.configure(self.holder)
        self.assertFalse(settings.DEBUG)

        event = self.get_child_node_event('/DEBUG')
        self.client.create('/DEBUG', json.dumps(True))
        event.wait(self.TIMEOUT)
        self.assertTrue(settings.DEBUG)

Example 2

Project: cmsplugin-sections Source File: schemamigration.py
Function: schemamigration
def schemamigration():
    # turn ``schemamigration.py --initial`` into
    # ``manage.py schemamigration cmsplugin_sections --initial`` and setup the 
    # enviroment
    from django.conf import settings

    from django.core.management import ManagementUtility
    settings.configure(
        INSTALLED_APPS=INSTALLED_APPS,
        ROOT_URLCONF=ROOT_URLCONF,
        DATABASES=DATABASES,
        TEMPLATE_CONTEXT_PROCESSORS=TEMPLATE_CONTEXT_PROCESSORS
    )
    argv = list(sys.argv)
    argv.insert(1, 'schemamigration')
    argv.insert(2, 'cmsplugin_sections')
    utility = ManagementUtility(argv)
    utility.execute()

Example 3

Project: django-simple-url Source File: runtests.py
Function: main
def main():
    BASE_DIR = os.path.abspath(os.path.dirname(__file__))
    sys.path.append(os.path.abspath(os.path.join(BASE_DIR, '..')))

    django.conf.settings.configure()
    django.setup()
    arguments = list(sys.argv)
    arguments.insert(1, 'test')
    django.core.management.execute_from_command_line(arguments)

Example 4

Project: django-calaccess-campaign-browser Source File: setup.py
Function: run
    def run(self):
        from django.conf import settings
        settings.configure(
            DATABASES={
                'default': {
                    'NAME': ':memory:',
                    'ENGINE': 'django.db.backends.sqlite3'
                }
            },
            INSTALLED_APPS=('calaccess_campaign_browser',),
            MIDDLEWARE_CLASSES=()
        )
        from django.core.management import call_command
        import django
        if django.VERSION[:2] >= (1, 7):
            django.setup()
        call_command('test', 'calaccess_campaign_browser')

Example 5

Project: korean Source File: koreantests.py
    def test_django_ext(self):
        from django.conf import settings
        from django.template import Context, Template
        settings.configure(INSTALLED_APPS=('korean.ext.django',))
        context = Context({'name': '용사', 'obj': '검'})
        expectation = '용사는 검을 획득했다.'
        templ1 = Template('''
        {% load korean %}
        {{ '용사은(는) 검을(를) 획득했다.'|proofread }}
        ''')
        assert templ1.render(Context()).strip() == expectation
        templ2 = Template('''
        {% load korean %}
        {% proofread %}
          {{ name }}은(는) {{ obj }}을(를) 획득했다.
        {% endproofread %}
        ''')
        assert templ2.render(context).strip() == expectation

Example 6

Project: menagerie Source File: tests.py
    def test_explicit_configure(self):
        # Ensure settings configured in ZooKeeper are reflected in Django settings.
        self.client.create('/READONLY', json.dumps(True))
        self.assertTrue(self.holder.READONLY)  # sanity check
        settings.configure(self.holder)
        self.assertTrue(settings.READONLY)

Example 7

Project: django-fakery Source File: runtests.py
Function: run_tests
def runtests(*test_args):
    import django.test.utils

    settings.configure(**SETTINGS)

    if django.VERSION[0:2] >= (1, 7):
        django.setup()

    runner_class = django.test.utils.get_runner(settings)
    test_runner = runner_class(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(['django_fakery'])
    sys.exit(failures)

Example 8

Project: edx-platform Source File: static_content.py
def main():
    """
    Generate
    Usage: static_content.py <output_root>
    """
    from django.conf import settings
    settings.configure()

    args = docopt(main.__doc__)
    root = path(args['<output_root>'])

    write_descriptor_js(root / 'descriptors/js')
    write_descriptor_styles(root / 'descriptors/css')
    write_module_js(root / 'modules/js')
    write_module_styles(root / 'modules/css')

Example 9

Project: django-template-server Source File: runserver_template.py
Function: run
def run(public=True, port=None):
    settings.configure(
        ROOT_URLCONF='runserver',
        DEBUG=True,
        TEMPLATE_DEBUG=True,
        TEMPLATE_DIRS=[TEMPLATE_DIR],
        APPEND_SLASH=False,
        STATIC_ROOT=STATIC_DIR,
        MEDIA_ROOT=MEDIA_DIR,
        STATIC_URL='/static/',
        MEDIA_URL='/media/',
    )
    port = port or get_open_port() 
    if public:
        location = '0.0.0.0:%s' % port
    else:
        location = '127.0.0.1:%s' % port
    call_command('runserver', location)

Example 10

Project: statirator Source File: main.py
Function: main
def main():
    if 'test' in sys.argv:
        os.environ.setdefault(
            "DJANGO_SETTINGS_MODULE", "statirator.test_settings")
    else:
        from django.conf import settings
        settings.configure(INSTALLED_APPS=('statirator.core', ))

    from django.core import management
    management.execute_from_command_line()

Example 11

Project: django-jsonfield Source File: setup.py
Function: run
    def run(self):
        from django.conf import settings
        settings.configure(
            DATABASES={'default': {'NAME': ':memory:', 'ENGINE': 'django.db.backends.sqlite3'}},
            INSTALLED_APPS=('jsonfield',)
        )
        from django.core.management import call_command
        import django

        if django.VERSION[:2] >= (1, 7):
            django.setup()
        call_command('test', 'jsonfield')

Example 12

Project: django-email-html Source File: quicktest.py
Function: tests_old
    def _tests_old(self):
        """
        Fire up the Django test suite from before version 1.2
        """
        INSTALLED_APPS, settings_test = self.get_custom_settings()

        settings.configure(DEBUG=True,
                           DATABASE_ENGINE='sqlite3',
                           DATABASE_NAME=os.path.join(self.DIRNAME, 'database.db'),
                           INSTALLED_APPS=self.INSTALLED_APPS + INSTALLED_APPS + self.apps,
                           **settings_test
                           )
        from django.test.simple import run_tests
        failures = run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)

Example 13

Project: django-email-html Source File: quicktest.py
    def _tests_1_2(self):
        """
        Fire up the Django test suite developed for version 1.2 and up
        """
        INSTALLED_APPS, settings_test = self.get_custom_settings()

        settings.configure(
            DEBUG=True,
            DATABASES=self.get_database(),
            INSTALLED_APPS=self.INSTALLED_APPS + INSTALLED_APPS + self.apps,
            **settings_test
        )

        from django.test.simple import DjangoTestSuiteRunner
        failures = DjangoTestSuiteRunner().run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)

Example 14

Project: django-yamlfield Source File: setup.py
Function: run
    def run(self):
        from django.conf import settings
        settings.configure(
            DATABASES={
                'default': {
                    'NAME': ':memory:',
                    'ENGINE': 'django.db.backends.sqlite3'
                }
            },
            MIDDLEWARE_CLASSES=(),
            INSTALLED_APPS=('yamlfield',)
        )
        from django.core.management import call_command
        import django
        django.setup()
        call_command('test', 'yamlfield')

Example 15

Project: django-sellmo Source File: __init__.py
Function: execute
    def execute(self):
        # Fool the Django ManagementUtility
        settings.configure()
        # Add the management/commands from sellmo
        # These are all global and do not need a project
        settings.INSTALLED_APPS = ['sellmo']
        super(ManagementUtility, self).execute()

Example 16

Project: django-simple-sso Source File: runtests.py
Function: run_tests
def run_tests():
    from django.conf import settings
    settings.configure(
        INSTALLED_APPS = INSTALLED_APPS,
        ROOT_URLCONF = ROOT_URLCONF,
        DATABASES = DATABASES,
        TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner',
        SSO_PRIVATE_KEY = 'private',
        SSO_PUBLIC_KEY = 'public',
        SSO_SERVER = 'http://localhost/server/',
    )

    # Run the test suite, including the extra validation tests.
    from django.test.utils import get_runner
    TestRunner = get_runner(settings)

    test_runner = TestRunner(verbosity=1, interactive=False, failfast=False)
    failures = test_runner.run_tests(['simple_sso'])
    return failures

Example 17

Project: django-uturn Source File: run_tests.py
Function: main
def main():
    settings.configure(
        INSTALLED_APPS = (
            'django.contrib.contenttypes',
            'uturn',
        ),
        DATABASES = {
            'default': {
                'ENGINE': 'django.db.backends.sqlite3'
            }
        },
        ROOT_URLCONF='uturn.tests.urls',
        TEMPLATE_CONTEXT_PROCESSORS = (
            'django.core.context_processors.request',
        ),
    )
    call_command('test', 'uturn')

Example 18

Project: django-options Source File: runtests.py
Function: configure
def configure():

    settings.configure(
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': ':memory:',
                }
        },
        INSTALLED_APPS=(
            'django.contrib.sites',
            'django_faker',
            'django_options',
            'picklefield',
            'django_extensions',
            ),
        SITE_ID=1,
    )

Example 19

Project: bootstrap-breadcrumbs Source File: conftest.py
Function: pytest_configure
def pytest_configure():
    settings.configure(
        DATABASES={'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': ':memory:'}},
        CACHES={'default': {
            'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}},
        INSTALLED_APPS=('django_bootstrap_breadcrumbs',),
        ROOT_URLCONF='tests.urls'
    )

Example 20

Project: django-healthchecks Source File: conftest.py
Function: pytest_configure
def pytest_configure():
    settings.configure(
        HEALTH_CHECKS={},
        MIDDLEWARE_CLASSES=[],
        CACHES={
            'default': {
                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
                'LOCATION': 'unique-snowflake',
            }
        },
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': 'db.sqlite',
            },
        }
    )

Example 21

Project: djangorestframework-expander Source File: conftest.py
Function: pytest_configure
def pytest_configure():
    from django.conf import settings

    settings.configure(
        ROOT_URLCONF='tests.project.urls',
        SECRET_KEY='not so secret',
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': 'db.sqlite',
            }
        },
        INSTALLED_APPS=[
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'rest_framework',
            'tests.project'
        ],
    )

Example 22

Project: django-instagram-api Source File: quicktest.py
Function: tests_old
    def _tests_old(self):
        """
        Fire up the Django test suite from before version 1.2
        """
        test_settings = self.custom_settings
        installed_apps = test_settings.pop('INSTALLED_APPS', ())
        settings.configure(
                DEBUG=True,
                DATABASE_ENGINE='sqlite3',
                DATABASE_NAME=os.path.join(self.DIRNAME, 'database.db'),
                INSTALLED_APPS=tuple(self.INSTALLED_APPS + installed_apps + self.apps),
                **test_settings
        )
        from django.test.simple import run_tests
        failures = run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)

Example 23

Project: django-faker Source File: runtests.py
Function: configure
def configure():

    from faker import Faker

    fake = Faker()

    settings.configure(
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': ':memory:',
                }
        },
        INSTALLED_APPS=(
            'django_faker',
            ),
        SITE_ID=1,
        SECRET_KEY=fake.sha1(),
    )

Example 24

Project: mezzanine Source File: mezzanine_project.py
Function: create_project
def create_project():
    # Put mezzanine.conf in INSTALLED_APPS so call_command can find
    # our command,
    settings.configure()
    settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + ['mezzanine.bin']
    argv = sys.argv[:1] + ['mezzanine_project'] + sys.argv[1:]
    management.execute_from_command_line(argv)

Example 25

Project: django-instagram-api Source File: quicktest.py
    def _tests_1_2(self):
        """
        Fire up the Django test suite developed for version 1.2 and up
        """
        test_settings = self.custom_settings
        installed_apps = test_settings.pop('INSTALLED_APPS', ())
        settings.configure(
            DEBUG=True,
            DATABASES=self.get_database(1.2),
            INSTALLED_APPS=tuple(self.INSTALLED_APPS + installed_apps + self.apps),
            **test_settings
        )
        from django.test.simple import DjangoTestSuiteRunner
        failures = DjangoTestSuiteRunner().run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)

Example 26

Project: mako Source File: basic.py
Function: django
def django(dirname, verbose=False):
    from django.conf import settings
    settings.configure(TEMPLATE_DIRS=[os.path.join(dirname, 'templates')])
    from django import template, templatetags
    from django.template import loader
    templatetags.__path__.append(os.path.join(dirname, 'templatetags'))
    tmpl = loader.get_template('template.html')

    def render():
        data = {'title': TITLE, 'user': USER, 'items': ITEMS}
        return tmpl.render(template.Context(data))

    if verbose:
        print(render())
    return render

Example 27

Project: django-rest-marshmallow Source File: conftest.py
Function: pytest_configure
def pytest_configure():
    from django.conf import settings

    settings.configure()

    try:
        import django
        django.setup()
    except AttributeError:
        pass

Example 28

Project: django-twitter-api Source File: quicktest.py
    def _tests_1_2(self):
        """
        Fire up the Django test suite developed for version 1.2 and up
        """
        INSTALLED_APPS, settings_test = self.get_custom_settings()

        settings.configure(
            DEBUG = True,
            DATABASES = self.get_database(),
            INSTALLED_APPS = self.INSTALLED_APPS + INSTALLED_APPS + self.apps,
            **settings_test
        )

        from django.test.simple import DjangoTestSuiteRunner
        failures = DjangoTestSuiteRunner().run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)

Example 29

Project: django-mailgun Source File: test_django_mailgun.py
def test_configuration():
    settings.configure(
        MAILGUN_ACCESS_KEY=123,
        MAILGUN_SERVER_NAME='abc'
    )
    MailgunBackend()

Example 30

Project: socrates Source File: renderers.py
Function: init
    def __init__(self, path):
        from django.conf import settings
        from django.template.loader import render_to_string

        path = os.path.abspath(path)
        settings.configure(DEBUG=True, TEMPLATE_DEBUG=True,
                           TEMPLATE_DIRS=[path])
        self._render = render_to_string

Example 31

Project: djangocms-styledlink Source File: schemamigration.py
Function: schemamigration
def schemamigration():
    # turn ``schemamigration.py --initial`` into
    # ``manage.py schemamigration cmsplugin_disqus --initial`` and setup the 
    # enviroment
    from django.conf import settings

    from django.core.management import ManagementUtility
    settings.configure(
        INSTALLED_APPS=INSTALLED_APPS,
        ROOT_URLCONF=ROOT_URLCONF,
        DATABASES=DATABASES,
        TEMPLATE_CONTEXT_PROCESSORS=TEMPLATE_CONTEXT_PROCESSORS
    )
    argv = list(sys.argv)
    argv.insert(1, 'schemamigration')
    argv.insert(2, 'djangocms_styledlink')
    utility = ManagementUtility(argv)
    utility.execute()

Example 32

Project: django-twitter-api Source File: quicktest.py
Function: tests_old
    def _tests_old(self):
        """
        Fire up the Django test suite from before version 1.2
        """
        INSTALLED_APPS, settings_test = self.get_custom_settings()

        settings.configure(DEBUG = True,
            DATABASE_ENGINE = 'sqlite3',
            DATABASE_NAME = os.path.join(self.DIRNAME, 'database.db'),
            INSTALLED_APPS = self.INSTALLED_APPS + INSTALLED_APPS + self.apps,
            **settings_test
        )
        from django.test.simple import run_tests
        failures = run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)

Example 33

Project: django-multi-gtfs Source File: run_tests.py
Function: main
def main(*paths):
    config = test_config()
    settings.configure(**config)

    from django.core import management
    if django_version >= 1 and django_point > 6:
        django.setup()

    failures = management.call_command(
        'test',
        *paths
    )
    sys.exit(failures)

Example 34

Project: django-twitter-api Source File: quicktest.py
    def _tests_1_7(self):
        """
        Fire up the Django test suite developed for version 1.7 and up
        """
        INSTALLED_APPS, settings_test = self.get_custom_settings()

        settings.configure(
            DEBUG = True,
            DATABASES = self.get_database(),
            MIDDLEWARE_CLASSES = ('django.middleware.common.CommonMiddleware',
                                  'django.middleware.csrf.CsrfViewMiddleware'),
            INSTALLED_APPS = self.INSTALLED_APPS + INSTALLED_APPS + self.apps,
            **settings_test
        )

        from django.test.simple import DjangoTestSuiteRunner
        import django
        django.setup()
        failures = DjangoTestSuiteRunner().run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)

Example 35

Project: Cactus_Refactored Source File: site.py
Function: set_up
    def setup(self):
        """
        Configure django to use both our template and pages folder as locations
        to look for included templates.
        """
        django_version_16 = float(django.VERSION[0]) + (float(django.VERSION[1]) / 10.0) > 1.5

        default_settings = {
            'STATIC_URL': '/static/',
            'TEMPLATE_DIRS': [self.paths['templates'], self.paths['pages']],
            'INSTALLED_APPS': [] if django_version_16 else ['django.contrib.markup']
        }

        user_settings = self.config.get('common', {}).get('django_settings', {})
        default_settings.update(user_settings)
        if not django_version_16 and not 'django.contrib.markup' in default_settings.get('INSTALLED_APPS'):
            default_settings['INSTALLED_APPS'] = ['django.contrib.markup'] + default_settings['INSTALLED_APPS']

        try:
            from django.conf import settings
            settings.configure(**default_settings)

            static_url = settings.STATIC_URL
            if not static_url.endswith(os.sep):
                static_url += os.sep
            settings.STATIC_URL_REL = static_url
            if settings.STATIC_URL_REL.startswith(os.sep):
                settings.STATIC_URL_REL = settings.STATIC_URL_REL[1:]
            settings.STATIC_URL_NAME = os.path.basename(os.path.dirname(static_url))

        except:
            pass

Example 36

Project: django-email-html Source File: quicktest.py
    def _tests_1_7(self):
        """
        Fire up the Django test suite developed for version 1.7 and up
        """
        INSTALLED_APPS, settings_test = self.get_custom_settings()

        settings.configure(
            DEBUG=True,
            DATABASES=self.get_database(),
            MIDDLEWARE_CLASSES=('django.middleware.common.CommonMiddleware',
                                'django.middleware.csrf.CsrfViewMiddleware'),
            INSTALLED_APPS = self.INSTALLED_APPS + INSTALLED_APPS + self.apps,
            **settings_test
        )

        from django.test.simple import DjangoTestSuiteRunner
        import django
        django.setup()
        failures = DjangoTestSuiteRunner().run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)

Example 37

Project: django-rest-messaging Source File: conftest.py
Function: pytest_configure
def pytest_configure():
    from django.conf import settings
    settings.configure(
        DEBUG_PROPAGATE_EXCEPTIONS=True,
        DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3',
                               'NAME': ':memory:'}},
        SITE_ID=1,
        SECRET_KEY='not very secret in tests',
        USE_I18N=True,
        USE_L10N=True,
        STATIC_URL='/static/',
        ROOT_URLCONF='tests.urls',
        TEMPLATE_LOADERS=(
            'django.template.loaders.filesystem.Loader',
            'django.template.loaders.app_directories.Loader',
        ),
        MIDDLEWARE_CLASSES=(
            'django.middleware.common.CommonMiddleware',
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.middleware.csrf.CsrfViewMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware',
            'rest_messaging.middleware.MessagingMiddleware'
        ),
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.sites',
            'django.contrib.messages',
            'django.contrib.staticfiles',

            'rest_framework',
            'rest_framework.authtoken',
            'tests',

            # rest_messaging
            'rest_messaging',
        ),
        PASSWORD_HASHERS=(
            'django.contrib.auth.hashers.SHA1PasswordHasher',
            'django.contrib.auth.hashers.PBKDF2PasswordHasher',
            'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
            'django.contrib.auth.hashers.BCryptPasswordHasher',
            'django.contrib.auth.hashers.MD5PasswordHasher',
            'django.contrib.auth.hashers.CryptPasswordHasher',
        ),
        REST_FRAMEWORK={
            'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
            'PAGE_SIZE': 100,
            'DEFAULT_PAGINATION_SERIALIZER_CLASS': 'rest_framework.pagination.PaginationSerializer',  # 3.0
            'PAGINATE_BY_PARAM': 100,  # 3.0
            'PAGINATE_BY': 10,  # 3.0
            'MAX_PAGINATE_BY': 100  # 3.0
        }
    )

    try:
        import django
        django.setup()
    except AttributeError:
        pass

Example 38

Project: django-activity-stream Source File: app_test_runner.py
def main():
    """
    The entry point for the script. This script is fairly basic. Here is a
    quick example of how to use it::
    
        app_test_runner.py [path-to-app]
    
    You must have Django on the PYTHONPATH prior to running this script. This
    script basically will bootstrap a Django environment for you.
    
    By default this script with use SQLite and an in-memory database. If you
    are using Python 2.5 it will just work out of the box for you.
    
    TODO: show more options here.
    """
    parser = OptionParser()
    parser.add_option("--DATABASE_ENGINE", dest="DATABASE_ENGINE", default="sqlite3")
    parser.add_option("--DATABASE_NAME", dest="DATABASE_NAME", default="")
    parser.add_option("--DATABASE_USER", dest="DATABASE_USER", default="")
    parser.add_option("--DATABASE_PASSWORD", dest="DATABASE_PASSWORD", default="")
    parser.add_option("--SITE_ID", dest="SITE_ID", type="int", default=1)
    
    options, args = parser.parse_args()
    
    # check for app in args
    try:
        app_path = args[0]
    except IndexError:
        print "You did not provide an app path."
        raise SystemExit
    else:
        if app_path.endswith("/"):
            app_path = app_path[:-1]
        parent_dir, app_name = os.path.split(app_path)
        sys.path.insert(0, parent_dir)
    
    settings.configure(**{
        "DATABASE_ENGINE": options.DATABASE_ENGINE,
        "DATABASE_NAME": options.DATABASE_NAME,
        "DATABASE_USER": options.DATABASE_USER,
        "DATABASE_PASSWORD": options.DATABASE_PASSWORD,
        "SITE_ID": options.SITE_ID,
        "ROOT_URLCONF": "",
        "TEMPLATE_LOADERS": (
            "django.template.loaders.filesystem.load_template_source",
            "django.template.loaders.app_directories.load_template_source",
        ),
        "TEMPLATE_DIRS": (
            os.path.join(os.path.dirname(__file__), "templates"),
        ),
        "INSTALLED_APPS": (
            # HACK: the admin app should *not* be required. Need to spend some
            # time looking into this. Django #8523 has a patch for this issue,
            # but was wrongly attached to that ticket. It should have its own
            # ticket.
            "django.contrib.admin",
            "django.contrib.auth",
            "django.contrib.contenttypes",
            "django.contrib.sessions",
            "django.contrib.sites",
            app_name,
        ),
    })
    call_command("test")

Example 39

Project: django-yarr Source File: runtests.py
Function: configure_django
def configure_django():
    installed_apps = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.admin',
        'yarr',
    )
    if os.environ.get('USE_SOUTH', ''):
        installed_apps += ('south',)

    settings.configure(
        DEBUG=True,
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
            }
        },
        ROOT_URLCONF='yarr.urls',
        USE_TZ=False,
        INSTALLED_APPS=installed_apps,
    )

Example 40

Project: django-email-html Source File: quicktest.py
Function: tests_1_8
    def _tests_1_8(self):
        """
        Fire up the Django test suite developed for version 1.7 and up
        """
        INSTALLED_APPS, settings_test = self.get_custom_settings()

        settings.configure(
            DEBUG=True,
            DATABASES=self.get_database(),
            MIDDLEWARE_CLASSES=('django.middleware.common.CommonMiddleware',
                                'django.middleware.csrf.CsrfViewMiddleware'),
            INSTALLED_APPS = self.INSTALLED_APPS + INSTALLED_APPS + self.apps,
            **settings_test
        )
        from django.test.runner import DiscoverRunner
        import django
        django.setup()
        failures = DiscoverRunner().run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)

Example 41

Project: informer Source File: conftest.py
Function: pytest_configure
def pytest_configure():
    settings.configure(
        INSTALLED_APPS=(
            'django.contrib.admin',
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.messages',
            'django.contrib.staticfiles',
            'informer'),
        MIDDLEWARE_CLASSES=(
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.middleware.common.CommonMiddleware',
            'django.middleware.csrf.CsrfViewMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware',
            'django.middleware.clickjacking.XFrameOptionsMiddleware',
            'django.middleware.security.SecurityMiddleware',
        ),
        DATABASES=DATABASE,
        CACHES={
            'default': {
                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
                'LOCATION': 'unique-snowflake',
            }
        },
        TEMPLATES=[{
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'APP_DIRS': True,
        }],
        ROOT_URLCONF='informer.urls',
        STATIC_URL='/static/',
        STATIC_ROOT='/static/',
        STATICFILES_DIRS=(
            os.path.join(BASE_DIR, 'static'),
        ),
        DJANGO_INFORMERS=(
            ('informer.checker.database', 'DatabaseInformer'),
            ('informer.checker.database', 'PostgresInformer'),
            ('informer.checker.storage', 'StorageInformer'),
            ('informer.checker.celery', 'CeleryInformer'),
            ('informer.checker.cache', 'CacheInformer'),
        ),
        DJANGO_INFORMER_PREVENT_SAVE_UNTIL=5,
        BROKER_BACKEND='memory',
        BROKER_URL='memory://',
        CELERY_ALWAYS_EAGER=True,
        CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
        CELERY_ACCEPT_CONTENT=['json'],
    )

Example 42

Project: django-generic-scaffold Source File: quicktest.py
    def run_tests(self):


        django_settings = {
            'DATABASES':{
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                }
            },
            'INSTALLED_APPS':self.INSTALLED_APPS + self.apps,
            'STATIC_URL':'/static/',
            'ROOT_URLCONF':'generic_scaffold.tests',
            'SILENCED_SYSTEM_CHECKS':['1_7.W001']
        }

        if django.VERSION >= (1, 8, 0):
            django_settings['TEMPLATES'] = [{
                    'BACKEND': 'django.template.backends.django.DjangoTemplates',
                    'APP_DIRS': True,
                    'OPTIONS': {
                        'context_processors': [
                            'django.template.context_processors.debug',
                            'django.template.context_processors.request',
                            'django.contrib.auth.context_processors.auth',
                            'django.contrib.messages.context_processors.messages',
                        ],
                    },
                }]

        settings.configure(**django_settings)

        if django.VERSION >= (1, 7, 0):
            # see: https://docs.djangoproject.com/en/dev/releases/1.7/#standalone-scripts
            django.setup()

        from django.test.runner import DiscoverRunner as Runner

        failures = Runner().run_tests(self.apps, verbosity=1)
        if failures:  # pragma: no cover
            sys.exit(failures)

Example 43

Project: django-pushy Source File: conftest.py
Function: pytest_configure
def pytest_configure():
    settings.configure(
        ROOT_URLCONF='tests.urls',

        ALLOWED_HOSTS=['testserver'],

        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': 'test_db'
            }
        },

        INSTALLED_APPS=[
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',

            'rest_framework',
            'pushy',
            'tests'
        ],

        PUSHY_GCM_API_KEY='SOME_TEST_KEY',
        PUSHY_GCM_JSON_PAYLOAD=False,
        PUSHY_APNS_CERTIFICATE_FILE='/var/apns/certificate'
    )

Example 44

Project: django-instagram-api Source File: quicktest.py
    def _tests_1_7(self):
        """
        Fire up the Django test suite developed for version 1.7 and up
        """
        test_settings = self.custom_settings
        installed_apps = test_settings.pop('INSTALLED_APPS', ())
        settings.configure(
            DEBUG=True,
            DATABASES=self.get_database(1.7),
            MIDDLEWARE_CLASSES=('django.middleware.common.CommonMiddleware',
                                'django.middleware.csrf.CsrfViewMiddleware'),
            INSTALLED_APPS=tuple(self.INSTALLED_APPS + installed_apps + self.apps),
            **test_settings
        )
        from django.test.simple import DjangoTestSuiteRunner
        import django
        django.setup()
        failures = DjangoTestSuiteRunner().run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)

Example 45

Project: django-mongoforms Source File: setup.py
    def run(self):

        if self.distribution.install_requires:
            self.distribution.fetch_build_eggs(
                self.distribution.install_requires)
        if self.distribution.tests_require:
            self.distribution.fetch_build_eggs(self.distribution.tests_require)

        import sys
        sys.path.insert(0, 'testprj')

        from testprj import settings as test_settings
        from django.conf import settings
        settings.configure(test_settings)

        from testprj.tests import mongoforms_test_runner as test_runner

        test_suite = test_runner.build_suite(['testapp'])
        test_runner.setup_test_environment()
        result = test_runner.run_suite(test_suite)
        test_runner.teardown_test_environment()

        return result

Example 46

Project: peeringdb-py Source File: localdb.py
def django_configure(cfg):
    db_fields = (
        'ENGINE',
        'HOST',
        'NAME',
        'PASSWORD',
        'PORT',
        'USER',
    )
    db = {}
    if 'database' in cfg:
        for k,v in cfg['database'].items():
            k = k.upper()
            if k in db_fields:
                db[k] = v

    else:
        db = {
            'ENGINE': 'sqlite3',
            'NAME': ':memory:',
        }

    extra = {
        'PEERINGDB_SYNC_URL': cfg['peeringdb'].get('url', ''),
        'PEERINGDB_SYNC_USERNAME': cfg['peeringdb'].get('user', ''),
        'PEERINGDB_SYNC_PASSWORD': cfg['peeringdb'].get('password', ''),
        'PEERINGDB_SYNC_ONLY': cfg['peeringdb'].get('sync_only', []),
        'PEERINGDB_SYNC_STRIP_TZ': True,
    }

    # open file reletive to config dir
    if '__config_dir__' in cfg:
        os.chdir(cfg['__config_dir__'])

    db['ENGINE'] = 'django.db.backends.' + db['ENGINE']

    settings.configure(
        INSTALLED_APPS=[
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.admin',
            'django.contrib.sessions',
            'django_peeringdb',
        ],
        DATABASES={
            'default': db
        },
        DEBUG=False,
        TEMPLATE_DEBUG=True,
        LOGGING={
            'version': 1,
            'disable_existing_loggers': False,
            'filters': {
                'dev_warnings': {
                    }
                },
            'handlers': {
                'stderr': {
                    'level': 'DEBUG',
                    'class': 'logging.StreamHandler',
                    'filters': ['dev_warnings'],
                    },
                },
            'loggers': {
                '': {
                    'handlers': ['stderr'],
                    'level': 'DEBUG',
                    'propagate': False
                },
            },
        },

        USE_TZ=False,
        # add user defined iso code for Kosovo
        COUNTRIES_OVERRIDE={
            'XK': _('Kosovo'),
        },
        **extra
    )

Example 47

Project: giotto Source File: __init__.py
def initialize(module_name=None):
    """
    Build the giotto settings object. This function gets called
    at the very begining of every request cycle.
    """
    import giotto
    from giotto.utils import random_string, switchout_keyvalue
    from django.conf import settings

    setattr(giotto, '_config', GiottoSettings())

    if not module_name:
        # For testing. No settings will be set.
        return

    project_module = importlib.import_module(module_name)
    project_path = os.path.dirname(project_module.__file__)
    setattr(giotto._config, 'project_path', project_path)

    try:
        secrets = importlib.import_module("%s.controllers.secrets" % module_name)
    except ImportError:
        secrets = None

    try:
        machine = importlib.import_module("%s.controllers.machine" % module_name)
    except ImportError:
        machine = None

    config = importlib.import_module("%s.controllers.config" % module_name)

    if config:
        for item in dir(config):
            setting_value = getattr(config, item)
            setattr(giotto._config, item, setting_value)

    if secrets:
        for item in dir(secrets):
            setting_value = getattr(secrets, item)
            setattr(giotto._config, item, setting_value)
    else:
        logging.warning("No secrets.py found")

    if machine:
        for item in dir(machine):
            setting_value = getattr(machine, item)
            setattr(giotto._config, item, setting_value)
    else:
        logging.warning("No machine.py found")

    settings.configure(
        SECRET_KEY=random_string(32),
        DATABASES=get_config('DATABASES'),
        INSTALLED_APPS=(module_name, 'giotto')
    )

    ss = get_config('session_store', None)
    if ss:
        class_ = switchout_keyvalue(ss)
        setattr(giotto._config, "session_store", class_())

    cache_engine = get_config("cache", None)
    if hasattr(cache_engine, 'lower'):
        # session engine was passed in as string, exchange for engine object.
        class_ = switchout_keyvalue(cache_engine)
        e = class_(host=get_config("cache_host", "localhost"))
        setattr(giotto._config, "cache_engine", e)

Example 48

Project: django-batch-requests Source File: conftest.py
Function: pytest_configure
def pytest_configure():
    from django.conf import settings

    settings.configure(
        DEBUG_PROPAGATE_EXCEPTIONS=True,
        DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3',
                               'NAME': ':memory:'}},
        SITE_ID=1,
        SECRET_KEY='not very secret in tests',
        USE_I18N=True,
        USE_L10N=True,
        STATIC_URL='/static/',
        ROOT_URLCONF='tests.urls',
        TEMPLATE_LOADERS=(
            'django.template.loaders.filesystem.Loader',
            'django.template.loaders.app_directories.Loader',
        ),
        MIDDLEWARE_CLASSES=(
            'django.middleware.common.CommonMiddleware',
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware',
        ),
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.sites',
            'django.contrib.staticfiles',
            'tests',
            'batch_requests',
        ),
        PASSWORD_HASHERS=(
            'django.contrib.auth.hashers.MD5PasswordHasher',
        ),
        BATCH_REQUESTS = {
            "HEADERS_TO_INCLUDE": ["HTTP_USER_AGENT", "HTTP_COOKIE"],
            "DEFAULT_CONTENT_TYPE": "application/xml",
            "USE_HTTPS": True,
            "MAX_LIMIT": 3
        }
    )
    try:
        import django
        django.setup()
    except AttributeError:
        pass

Example 49

Project: django-instagram-api Source File: quicktest.py
Function: tests_1_8
    def _tests_1_8(self):
        """
        Fire up the Django test suite developed for version 1.8 and up
        """
        test_settings = self.custom_settings
        installed_apps = test_settings.pop('INSTALLED_APPS', ())
        settings.configure(
            DEBUG=True,
            DATABASES=self.get_database(1.8),
            MIDDLEWARE_CLASSES=('django.middleware.common.CommonMiddleware',
                                'django.middleware.csrf.CsrfViewMiddleware'),
            INSTALLED_APPS=tuple(self.INSTALLED_APPS + installed_apps + self.apps),
            **test_settings
        )
        from django.test.runner import DiscoverRunner
        import django
        django.setup()
        failures = DiscoverRunner().run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)

Example 50

Project: django-hitcount Source File: conftest.py
Function: pytest_configure
def pytest_configure():
    from django.conf import settings

    settings.configure(
        DEBUG_PROPAGATE_EXCEPTIONS=True,
        DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3',
                               'NAME': ':memory:'}},
        SITE_ID=1,
        SECRET_KEY='HitCounts Rock!',
        DEBUG=True,
        TEMPLATE_DEBUG=True,
        ALLOWED_HOSTS=[],
        USE_I18N=True,
        USE_L10N=True,
        STATIC_URL='/static/',
        MIDDLEWARE_CLASSES=(
            'django.middleware.common.CommonMiddleware',
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware',
        ),
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.sites',
            'django.contrib.staticfiles',
            'blog',
            'hitcount',
            'tests',
        ),
        ROOT_URLCONF='example_project.urls',
        SESSION_ENGINE='django.contrib.sessions.backends.file',
        TEMPLATES=[
            {
                'BACKEND': 'django.template.backends.django.DjangoTemplates',
                'APP_DIRS': True,
            },
        ],
        # HitCount Variables (default values)
        HITCOUNT_KEEP_HIT_ACTIVE={'days': 7},
        HITCOUNT_HITS_PER_IP_LIMIT=0,
        HITCOUNT_EXCLUDE_USER_GROUP=(),
        HITCOUNT_KEEP_HIT_IN_DATABASE={'days': 30},
    )

    try:
        import django
        django.setup()
    except AttributeError:
        pass

    # so we can reuse this function when testing directly from Django
    # via: ./runtests.py --django
    return settings
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3