python类configure()的实例源码

makemigrations.py 文件源码 项目:pinax-news 作者: pinax 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def run(*args):
    if not settings.configured:
        settings.configure(**DEFAULT_SETTINGS)

    django.setup()

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

    django.core.management.call_command(
        "makemigrations",
        "pinax_news",
        *args
    )
conftest.py 文件源码 项目:seekconnection 作者: seekhealing 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def pytest_configure():
    settings.configure(DATABASES=seekconnection_settings.DATABASES)
conftest.py 文件源码 项目:django-rest-framework-client 作者: qvantel 项目源码 文件源码 阅读 130 收藏 0 点赞 0 评论 0
def pytest_configure():
    settings.configure(INSTALLED_APPS=[
        'django.contrib.contenttypes',
    ])
    django.setup()
makemigrations.py 文件源码 项目:pinax-cohorts 作者: pinax 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def run(*args):
    if not settings.configured:
        settings.configure(**DEFAULT_SETTINGS)

    django.setup()

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

    django.core.management.call_command(
        "makemigrations",
        "pinax_cohorts",
        *args
    )
runner.py 文件源码 项目:django-partial-index 作者: mattiaslinnap 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def main(args):
    # Since this test suite is designed to be ran outside of ./manage.py test, we need to do some setup first.
    import django
    from django.conf import settings
    settings.configure(INSTALLED_APPS=['testapp'], DATABASES=DATABASES_FOR_DB[args.db])
    django.setup()

    from django.test.runner import DiscoverRunner
    test_runner = DiscoverRunner(top_level=TESTS_DIR, interactive=False, keepdb=False)
    failures = test_runner.run_tests(['tests'])
    if failures:
        sys.exit(1)
test_ext_django.py 文件源码 项目:Callandtext 作者: iaora 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def test_01_overwrite_detection(self):
        "test detection of foreign monkeypatching"
        # NOTE: this sets things up, and spot checks two methods,
        #       this should be enough to verify patch manager is working.
        # TODO: test unpatch behavior honors flag.

        # configure plugin to use sample context
        config = "[passlib]\nschemes=des_crypt\n"
        self.load_extension(PASSLIB_CONFIG=config)

        # setup helpers
        import django.contrib.auth.models as models
        from passlib.ext.django.models import _manager
        def dummy():
            pass

        # mess with User.set_password, make sure it's detected
        orig = models.User.set_password
        models.User.set_password = dummy
        with self.assertWarningList("another library has patched.*User\.set_password"):
            _manager.check_all()
        models.User.set_password = orig

        # mess with models.check_password, make sure it's detected
        orig = models.check_password
        models.check_password = dummy
        with self.assertWarningList("another library has patched.*models:check_password"):
            _manager.check_all()
        models.check_password = orig
makemessages.py 文件源码 项目:django-private-storage 作者: edoburu 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def main():
    if not settings.configured:
        module_root = path.dirname(path.realpath(__file__))

        settings.configure(
            DEBUG = False,
            INSTALLED_APPS = (
                'private_storage',
            ),
        )

    if django.VERSION >= (1,7):
        django.setup()

    makemessages()
udjango_mocked.py 文件源码 项目:testing 作者: donkirkby 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def setup():
    DB_FILE = NAME + '.db'
    with open(DB_FILE, 'w'):
        pass  # wipe the database
    settings.configure(
        DEBUG=True,
        DATABASES={
            DEFAULT_DB_ALIAS: {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': DB_FILE}},
        LOGGING={'version': 1,
                 'disable_existing_loggers': False,
                 'formatters': {
                    'debug': {
                        'format': '%(asctime)s[%(levelname)s]'
                                  '%(name)s.%(funcName)s(): %(message)s',
                        'datefmt': '%Y-%m-%d %H:%M:%S'}},
                 'handlers': {
                    'console': {
                        'level': 'DEBUG',
                        'class': 'logging.StreamHandler',
                        'formatter': 'debug'}},
                 'root': {
                    'handlers': ['console'],
                    'level': 'WARN'},
                 'loggers': {
                    "django.db": {"level": "WARN"}}})
    app_config = AppConfig(NAME, sys.modules['__main__'])
    apps.populate([app_config])
    django.setup()
    original_new_func = ModelBase.__new__

    @staticmethod
    def patched_new(cls, name, bases, attrs):
        if 'Meta' not in attrs:
            class Meta:
                app_label = NAME
            attrs['Meta'] = Meta
        return original_new_func(cls, name, bases, attrs)
    ModelBase.__new__ = patched_new
udjango.py 文件源码 项目:testing 作者: donkirkby 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def setup():
    DB_FILE = NAME + '.db'
    with open(DB_FILE, 'w'):
        pass  # wipe the database
    settings.configure(
        DEBUG=True,
        DATABASES={
            DEFAULT_DB_ALIAS: {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': DB_FILE}},
        LOGGING={'version': 1,
                 'disable_existing_loggers': False,
                 'formatters': {
                    'debug': {
                        'format': '%(asctime)s[%(levelname)s]'
                                  '%(name)s.%(funcName)s(): %(message)s',
                        'datefmt': '%Y-%m-%d %H:%M:%S'}},
                 'handlers': {
                    'console': {
                        'level': 'DEBUG',
                        'class': 'logging.StreamHandler',
                        'formatter': 'debug'}},
                 'root': {
                    'handlers': ['console'],
                    'level': 'WARN'},
                 'loggers': {
                    "django.db": {"level": "WARN"}}})
    app_config = AppConfig(NAME, sys.modules['__main__'])
    apps.populate([app_config])
    django.setup()
    original_new_func = ModelBase.__new__

    @staticmethod
    def patched_new(cls, name, bases, attrs):
        if 'Meta' not in attrs:
            class Meta:
                app_label = NAME
            attrs['Meta'] = Meta
        return original_new_func(cls, name, bases, attrs)
    ModelBase.__new__ = patched_new
udjango_mock_set.py 文件源码 项目:testing 作者: donkirkby 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def setup():
    DB_FILE = NAME + '.db'
    with open(DB_FILE, 'w'):
        pass  # wipe the database
    settings.configure(
        DEBUG=True,
        DATABASES={
            DEFAULT_DB_ALIAS: {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': DB_FILE}},
        LOGGING={'version': 1,
                 'disable_existing_loggers': False,
                 'formatters': {
                    'debug': {
                        'format': '%(asctime)s[%(levelname)s]'
                                  '%(name)s.%(funcName)s(): %(message)s',
                        'datefmt': '%Y-%m-%d %H:%M:%S'}},
                 'handlers': {
                    'console': {
                        'level': 'DEBUG',
                        'class': 'logging.StreamHandler',
                        'formatter': 'debug'}},
                 'root': {
                    'handlers': ['console'],
                    'level': 'WARN'},
                 'loggers': {
                    "django.db": {"level": "WARN"}}})
    app_config = AppConfig(NAME, sys.modules['__main__'])
    apps.populate([app_config])
    django.setup()
    original_new_func = ModelBase.__new__

    @staticmethod
    def patched_new(cls, name, bases, attrs):
        if 'Meta' not in attrs:
            class Meta:
                app_label = NAME
            attrs['Meta'] = Meta
        return original_new_func(cls, name, bases, attrs)
    ModelBase.__new__ = patched_new
conftest.py 文件源码 项目:django-skivvy 作者: Cadasta 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def pytest_configure():
    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,
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.sites',
            'django.contrib.messages',
            'django.contrib.staticfiles',
            'tests',
        ),
        ROOT_URLCONF='tests.urls',
        MIDDLEWARE_CLASSES=(
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware',
        ),
        TEMPLATES=[
            {
                'BACKEND': 'django.template.backends.django.DjangoTemplates',
                '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',
                    ],
                    'loaders': [
                        'django.template.loaders.filesystem.Loader',
                        'django.template.loaders.app_directories.Loader'
                    ],
                },
            },
        ]
    )
conftest.py 文件源码 项目:aa-stripe 作者: ArabellaTech 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def pytest_configure():
    from django.conf import settings

    settings.configure(
        DEBUG_PROPAGATE_EXCEPTIONS=True,
        DATABASES={
            "default": {
                "ENGINE": "django.db.backends.sqlite3",
                "NAME": ":memory:",
            }
        },
        SECRET_KEY="not very secret in tests",
        USE_I18N=True,
        USE_L10N=True,
        USE_TZ=True,
        INSTALLED_APPS=(
            "django.contrib.auth",
            "django.contrib.contenttypes",
            "django.contrib.admin",
            "django.contrib.sites",
            "rest_framework",
            "aa_stripe"
        ),
        ROOT_URLCONF="aa_stripe.api_urls",
        TESTING=True,

        ENV_PREFIX="test-env",
        STRIPE_SETTINGS_API_KEY="apikey",
        STRIPE_SETTINGS_WEBHOOK_ENDPOINT_SECRET="fake"
    )
conftest.py 文件源码 项目:news 作者: kuc2477 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def pytest_configure():
    # configure django settings
    settings.configure(**DJANGO_SETTINGS_DICT)
test_ext_django.py 文件源码 项目:Sudoku-Solver 作者: ayush1997 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_01_overwrite_detection(self):
        """test detection of foreign monkeypatching"""
        # NOTE: this sets things up, and spot checks two methods,
        #       this should be enough to verify patch manager is working.
        # TODO: test unpatch behavior honors flag.

        # configure plugin to use sample context
        config = "[passlib]\nschemes=des_crypt\n"
        self.load_extension(PASSLIB_CONFIG=config)

        # setup helpers
        import django.contrib.auth.models as models
        from passlib.ext.django.models import _manager
        def dummy():
            pass

        # mess with User.set_password, make sure it's detected
        orig = models.User.set_password
        models.User.set_password = dummy
        with self.assertWarningList("another library has patched.*User\.set_password"):
            _manager.check_all()
        models.User.set_password = orig

        # mess with models.check_password, make sure it's detected
        orig = models.check_password
        models.check_password = dummy
        with self.assertWarningList("another library has patched.*models:check_password"):
            _manager.check_all()
        models.check_password = orig
command_utils.py 文件源码 项目:tetre 作者: aoldoni 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def setup_django_template_system():
    """Initialises the Django templating system as to be used standalone.
    """
    settings.configure()
    settings.TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates'
        }
    ]
    django.setup()
test_middleware.py 文件源码 项目:opencensus-python 作者: census-instrumentation 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def setUp(self):
        from django.conf import settings as django_settings
        from django.test.utils import setup_test_environment

        if not django_settings.configured:
            django_settings.configure()
        setup_test_environment()
test_config.py 文件源码 项目:opencensus-python 作者: census-instrumentation 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def setUp(self):
        from django.conf import settings as django_settings
        from django.test.utils import setup_test_environment

        if not django_settings.configured:
            django_settings.configure()
        setup_test_environment()
runtests.py 文件源码 项目:django-elasticsearch-dsl 作者: sabricot 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_settings():
        settings.configure(
            DEBUG=True,
            USE_TZ=True,
            DATABASES={
                "default": {
                    "ENGINE": "django.db.backends.sqlite3",
                }
            },
            INSTALLED_APPS=[
                "django.contrib.auth",
                "django.contrib.contenttypes",
                "django.contrib.sites",
                "django_elasticsearch_dsl",
                "tests",
            ],
            SITE_ID=1,
            MIDDLEWARE_CLASSES=(),
            ELASTICSEARCH_DSL={
                'default': {
                    'hosts': os.environ.get('ELASTICSEARCH_URL',
                                            'localhost:9200')
                },
            },
        )

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

        return settings
conftest.py 文件源码 项目:kaneda 作者: APSL 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def pytest_configure():
    from django.conf import settings
    settings.configure()
quicktest.py 文件源码 项目:django-mapproxy 作者: terranodo 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def _old_tests(self):
        """
        Fire up the Django test suite from before version 1.2
        """
        settings.configure(DEBUG = True,
           DATABASE_ENGINE = 'sqlite3',
           DATABASE_NAME = os.path.join(self.DIRNAME, 'database.db'),
           INSTALLED_APPS = self.INSTALLED_APPS + self.apps
        )
        from django.test.simple import run_tests
        failures = run_tests(self.apps, verbosity=1)
        if failures:
            sys.exit(failures)


问题


面经


文章

微信
公众号

扫码关注公众号