mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-12-24 23:45:16 +11:00
Monkeytype Django setup
This commit is contained in:
parent
426a8970a6
commit
ba0faeffd0
1 changed files with 29 additions and 0 deletions
29
dpaste/monkeytype.py
Normal file
29
dpaste/monkeytype.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
from contextlib import contextmanager
|
||||
from typing import Iterator
|
||||
|
||||
from monkeytype.config import DefaultConfig
|
||||
|
||||
|
||||
class DpasteConfig(DefaultConfig):
|
||||
@contextmanager
|
||||
def cli_context(self, command: str) -> Iterator[None]:
|
||||
"""
|
||||
Django Settings setup
|
||||
"""
|
||||
try:
|
||||
import dpaste.settings.local # isort: skip
|
||||
|
||||
settings = "dpaste.settings.local"
|
||||
except ImportError:
|
||||
settings = "dpaste.settings.base"
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings)
|
||||
|
||||
import django # isort: skip
|
||||
|
||||
django.setup()
|
||||
yield
|
||||
|
||||
|
||||
CONFIG = DpasteConfig()
|
Loading…
Reference in a new issue