File: setup_django.py

package info (click to toggle)
python-semantic-version 2.10.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 348 kB
  • sloc: python: 2,586; makefile: 204
file content (29 lines) | stat: -rw-r--r-- 768 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding: utf-8 -*-
# Copyright (c) The python-semanticversion project

try:  # pragma: no cover
    import django
    django_loaded = True
except ImportError:  # pragma: no cover
    django_loaded = False
    django = None


if django_loaded:
    from django.conf import settings
    if not settings.configured:
        settings.configure(
            DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': 'tests/db/test.sqlite',
                }
            },
            INSTALLED_APPS=[
                'tests.django_test_app',
            ],
            MIDDLEWARE_CLASSES=[],
        )
    django.setup()
    from django.apps import apps
    apps.populate(settings.INSTALLED_APPS)