當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.configure方法代碼示例

本文整理匯總了Python中django.conf.settings.configure方法的典型用法代碼示例。如果您正苦於以下問題:Python settings.configure方法的具體用法?Python settings.configure怎麽用?Python settings.configure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.conf.settings的用法示例。


在下文中一共展示了settings.configure方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _tests

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def _tests(self):
        settings.configure(
            DEBUG=True,
            DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': os.path.join(self.DIRNAME, 'database.db'),
                }
            },
            INSTALLED_APPS=self.INSTALLED_APPS + self.apps,
            MIDDLEWARE=self.MIDDLEWARE,
            ROOT_URLCONF='django_classified.tests.urls',
            STATIC_URL='/static/',
            TEMPLATES=self.TEMPLATES,
            SITE_ID=1
        )

        from django.test.runner import DiscoverRunner
        test_runner = DiscoverRunner()
        django.setup()

        failures = test_runner.run_tests(self.apps)
        if failures:
            sys.exit(failures) 
開發者ID:slyapustin,項目名稱:django-classified,代碼行數:26,代碼來源:quicktest.py

示例2: runtests

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def runtests(*test_args):
    if not settings.configured:
        settings.configure(**DEFAULT_SETTINGS)

    # Compatibility with Django 1.7's stricter initialization
    if hasattr(django, "setup"):
        django.setup()

    parent = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, parent)

    try:
        from django.test.runner import DiscoverRunner
        runner_class = DiscoverRunner
        test_args = ["pinax.documents.tests"]
    except ImportError:
        from django.test.simple import DjangoTestSuiteRunner
        runner_class = DjangoTestSuiteRunner
        test_args = ["tests"]

    failures = runner_class(verbosity=1, interactive=True, failfast=False).run_tests(test_args)
    sys.exit(failures) 
開發者ID:pinax,項目名稱:pinax-documents,代碼行數:24,代碼來源:runtests.py

示例3: configure

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def configure():
    from faker import Faker
    fake = Faker()

    settings.configure(
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': ':memory:',
            }
        },
        INSTALLED_APPS=(
            'django_seed',
            'django_nose',
        ),
        TEST_RUNNER = 'django_nose.NoseTestSuiteRunner',
        NOSE_ARGS = [
            '--with-coverage',
            '--cover-package=django_seed',
        ],
        SITE_ID=1,
        SECRET_KEY=fake.sha1(),
    ) 
開發者ID:Brobin,項目名稱:django-seed,代碼行數:25,代碼來源:runtests.py

示例4: run_tests

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def run_tests():
    # Making Django run this way is a two-step process. First, call
    # settings.configure() to give Django settings to work with:
    from django.conf import settings

    settings.configure(**SETTINGS_DICT)

    # Then, call django.setup() to initialize the application registry
    # and other bits:
    import django

    django.setup()

    # Now we instantiate a test runner...
    from django.test.utils import get_runner

    TestRunner = get_runner(settings)

    # And then we run tests and return the results.
    test_runner = TestRunner(verbosity=2, interactive=True)
    failures = test_runner.run_tests(["tests"])
    sys.exit(failures) 
開發者ID:ubernostrum,項目名稱:pwned-passwords-django,代碼行數:24,代碼來源:runtests.py

示例5: pytest_configure

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def pytest_configure(config):
    from django.conf import settings

    settings.configure(
        AUTHENTICATION_BACKENDS=[
            "tests.base.FooPasswordBackend",
            "tests.base.StubPasswordBackend",
        ],
        DEBUG=True,
        DATABASE_ENGINE="sqlite3",
        DATABASES={
            "default": {
                "NAME": ":memory:",
                "ENGINE": "django.db.backends.sqlite3",
                "TEST_NAME": ":memory:",
            },
        },
        DATABASE_NAME=":memory:",
        TEST_DATABASE_NAME=":memory:",
        INSTALLED_APPS=INSTALLED_APPS,
        MIDDLEWARE_CLASSES=MIDDLEWARE_CLASSES,
        PASSWORD_HASHERS=["django.contrib.auth.hashers.MD5PasswordHasher"],
        ROOT_URLCONF="tests.urls",
    ) 
開發者ID:mattrobenolt,項目名稱:django-sudo,代碼行數:26,代碼來源:conftest.py

示例6: setup_django

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def setup_django():
    import django
    from django.conf import settings
    if not settings.configured:
        settings.configure(
            DEBUG=True,
            DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': ':memory:',
                }
            },
            INSTALLED_APPS=(
                'django.contrib.admin',
                'django.contrib.auth',
                'django.contrib.contenttypes',
                'django.contrib.sessions',
                'django.contrib.messages',
                'django_ftpserver',
            )
        )
    django.setup()
    from django.apps import apps
    if not apps.ready:
        apps.populate() 
開發者ID:tokibito,項目名稱:django-ftpserver,代碼行數:27,代碼來源:conf.py

示例7: pytest_configure

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def pytest_configure():
    from django.conf import settings

    WEBDAV_URL = os.getenv('WEBDAV_URL', 'http://127.0.0.1:8080/')
    WEBDAV_PUBLIC_URL = os.getenv('WEBDAV_PUBLIC_URL',
                                  'http://127.0.0.1:8080/')
    WEBDAV_LISTING_BACKEND = os.getenv('WEBDAV_LISTING_BACKEND')

    settings.configure(
        INSTALLED_APPS=['django_webdav_storage'],
        MIDDLEWARE_CLASSES=['django.middleware.common.CommonMiddleware'],
        MIDDLEWARES=['django.middleware.common.CommonMiddleware'],
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': ':MEMORY:'
            }
        },
        WEBDAV_URL=WEBDAV_URL,
        WEBDAV_PUBLIC_URL=WEBDAV_PUBLIC_URL,
        WEBDAV_RECURSIVE_MKCOL=True,
        WEBDAV_LISTING_BACKEND=WEBDAV_LISTING_BACKEND
    ) 
開發者ID:marazmiki,項目名稱:django-webdav-storage,代碼行數:25,代碼來源:conftest.py

示例8: runtests

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def runtests(*test_args):
    if not settings.configured:
        settings.configure(**DEFAULT_SETTINGS)

    django.setup()

    parent = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, parent)

    try:
        from django.test.runner import DiscoverRunner
        runner_class = DiscoverRunner
        if not test_args:
            test_args = ["pinax.forums.tests"]
    except ImportError:
        from django.test.simple import DjangoTestSuiteRunner
        runner_class = DjangoTestSuiteRunner
        test_args = ["tests"]

    failures = runner_class(verbosity=1, interactive=True, failfast=False).run_tests(test_args)
    sys.exit(failures) 
開發者ID:pinax,項目名稱:pinax-forums,代碼行數:23,代碼來源:runtests.py

示例9: run_tests

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def run_tests():
    # First configure settings, then call django.setup() to initialise
    from django.conf import settings

    settings.configure(**SETTINGS_DICT)
    import django

    django.setup()

    # Now create the test runner
    from django.test.utils import get_runner

    TestRunner = get_runner(settings)

    # And then we run tests and return the results.
    test_runner = TestRunner(verbosity=2, interactive=True)
    failures = test_runner.run_tests(["tests"])
    sys.exit(failures) 
開發者ID:kogan,項目名稱:django-subscriptions,代碼行數:20,代碼來源:runtests.py

示例10: test_django_cache

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def test_django_cache(self):
        try:
            from django.conf import settings
            settings.configure(CACHE_BACKEND = 'locmem://')
            from django.core.cache import cache
        except ImportError:
            # no Django, so nothing to test
            return
        
        congress = Congress(API_KEY, cache)
        
        self.assertEqual(congress.http.cache, cache)
        self.assertEqual(congress.members.http.cache, cache)
        self.assertEqual(congress.bills.http.cache, cache)
        self.assertEqual(congress.votes.http.cache, cache)
        
        try:
            bills = congress.bills.introduced('house')
        except Exception as e:
            self.fail(e) 
開發者ID:eyeseast,項目名稱:propublica-congress,代碼行數:22,代碼來源:test.py

示例11: runtests

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def runtests():
    if not settings.configured:
        settings.configure(**DEFAULT_SETTINGS)
    django.setup()
    from spillway.models import upload_to
    os.mkdir(os.path.join(TMPDIR, upload_to.path))
    parent = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, parent)
    try:
        from django.test.runner import DiscoverRunner
        runner_class = DiscoverRunner
    except ImportError:
        from django.test.simple import DjangoTestSuiteRunner
        runner_class = DjangoTestSuiteRunner
    try:
        status = runner_class(
            verbosity=1, interactive=True, failfast=False).run_tests(['tests'])
    except Exception:
        traceback.print_exc()
        status = 1
    finally:
        teardown()
    sys.exit(status) 
開發者ID:bkg,項目名稱:django-spillway,代碼行數:25,代碼來源:runtests.py

示例12: pytest_configure

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def pytest_configure():
    from django.conf import settings

    settings.configure(
        DEBUG=True,
        USE_TZ=True,
        DATABASES={
            "default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "test.sqlite3"}
        },
        INSTALLED_APPS=[
            "django.contrib.auth",
            "django.contrib.contenttypes",
            # "django.contrib.sites",
            "taggit",
            "taggit_labels",
            "test_app",
        ],
        MIDDLEWARE_CLASSES=(),
        SITE_ID=1,
    )
    try:
        django.setup()
    except AttributeError:
        # Django 1.7 or lower
        pass 
開發者ID:bennylope,項目名稱:django-taggit-labels,代碼行數:27,代碼來源:conftest.py

示例13: configure

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def configure():
    from django.conf import settings

    settings.configure(
        DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3',
                               'NAME': ':memory:'}},
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.sites',
            'django.contrib.staticfiles',

            'rest_framework',
            'tests',
        ),
    )

    import django
    django.setup() 
開發者ID:Onyo,項目名稱:django-rest-framework-cache,代碼行數:22,代碼來源:__init__.py

示例14: django_configure

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def django_configure():
    from django.conf import settings

    settings.configure(
        INSTALLED_APPS=(
            'django.contrib.admin',
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.sites',
            'django.contrib.staticfiles',

            'rest_framework',
            'rest_framework_simplejwt',
            'rest_framework_simplejwt.token_blacklist',
        ),
    )

    try:
        import django
        django.setup()
    except AttributeError:
        pass 
開發者ID:SimpleJWT,項目名稱:django-rest-framework-simplejwt,代碼行數:25,代碼來源:conf.py

示例15: read_template_source

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import configure [as 別名]
def read_template_source(filename):
    """Read the source of a Django template, returning the Unicode text."""
    # Import this late to be sure we don't trigger settings machinery too
    # early.
    from django.conf import settings

    if not settings.configured:
        settings.configure()

    with open(filename, "rb") as f:
        # The FILE_CHARSET setting will be removed in 3.1:
        # https://docs.djangoproject.com/en/3.0/ref/settings/#file-charset
        if django.VERSION >= (3, 1):
            charset = 'utf-8'
        else:
            charset = settings.FILE_CHARSET
        text = f.read().decode(charset)

    return text 
開發者ID:nedbat,項目名稱:django_coverage_plugin,代碼行數:21,代碼來源:plugin.py


注:本文中的django.conf.settings.configure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。