File: decorators.py

package info (click to toggle)
python-django-dynamic-fixture 4.0.1-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 616 kB
  • sloc: python: 3,909; makefile: 237; sh: 6
file content (29 lines) | stat: -rw-r--r-- 718 bytes parent folder | download | duplicates (2)
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

from django.conf import settings


DATABASE_ENGINE = settings.DATABASES['default']['ENGINE']

SQLITE3 = 'sqlite3'
POSTGRES = 'postgresql'
MYSQL = 'mysql'
ORACLE = 'oracle'
SQLSERVER = 'pyodbc'


def skip_for_database(database):
    def main_decorator(testcase_function):
        def wrapper(*args, **kwargs):
            if database not in DATABASE_ENGINE:
                testcase_function(*args, **kwargs)
        return wrapper
    return main_decorator


def only_for_database(database):
    def main_decorator(testcase_function):
        def wrapper(*args, **kwargs):
            if database in DATABASE_ENGINE:
                testcase_function(*args, **kwargs)
        return wrapper
    return main_decorator