def pytest_configure(): configure() import coredb.signals.runs # noqa from polycommon import conf from coredb import operations conf.validate_and_setup() operations.validate_and_setup() import polycommon.options.conf_subscriptions # noqa
def makeSettings(): """Selects an appropriate settings function""" import os import simplejson as json if os.getenv('settings'): with open('config.json', 'r') as cfg: config = json.load(cfg) settings = literal_eval(os.getenv('settings')) config["logging"] = settings[0] config["dmLog"] = settings[1] config["audit"] = settings[2] config["deleteLog"] = settings[3] with open('config.json', 'w') as cfg: json.dump(config, cfg) print('Settings have been pulled from environment variables.') else: import settings settings.configure()
from django.conf import settings if len(sys.argv) > 1 and 'postgres' in sys.argv: sys.argv.remove('postgres') db_engine = 'django.db.backends.postgresql_psycopg2' db_name = 'test_main' else: db_engine = 'django.db.backends.sqlite3' db_name = '' if not settings.configured: settings.configure( DATABASES=dict(default=dict(ENGINE=db_engine, NAME=db_name)), INSTALLED_APPS = [ 'django.contrib.contenttypes', 'genericm2m', 'genericm2m.genericm2m_tests', ], ) from django.test.utils import get_runner def runtests(*test_args): if not test_args: if sys.version_info[0] > 2: test_args = ['genericm2m.genericm2m_tests'] else: test_args = ["genericm2m_tests"] parent = dirname(abspath(__file__)) sys.path.insert(0, parent)
#!/usr/bin/env python import os, sys, datetime import json from settings import * from django.conf import settings from django.template import Context, loader # working directory (where script is located) WD = sys.path[0] + os.sep settings.configure( TEMPLATE_DIRS = ( WD + "templates", ), TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', ) ) def main(*args): # open model descriptor try: f = open(WD + 'model_descriptor.json', 'rb') model_descriptor = json.load(f) f.close() #print(json.dumps(model_descriptor)) print( "Model descriptor successfully loaded." ) except Exception as e: sys.exit( "Error loading model descriptor: " + str(e) )
# <LicenseText> # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # def run(): from RegistrationPage import RegistrationPage page = RegistrationPage() page.render() return # main if __name__ == "__main__": print 'Content-type: text/html' print import settings settings.configure() run() # version __id__ = "$Id" # End of file
if contrib_dir not in sys.path: sys.path.insert(1, contrib_dir) # set the path for tornado. This is kind of a hack since the call context # changes throughout this file. os.environ["DJANGO_SETTINGS_MODULE"] = "winnebadjango.settings" from tornado.httpserver import HTTPServer from tornado.ioloop import PeriodicCallback import tornado.ioloop as ioloop import tornado.web import tornado.wsgi import settings settings.configure() import logging from handlers import core, atlas import urls as base_urls from tornado.httpserver import HTTPServer from django.core.handlers import wsgi as dwsgi from lib.middleware.wsgi import DjangoWSGIContainer logger = logging.getLogger("ef5") bind_handlers = set()
#!/usr/bin/python # # Copyright 2018-2020 Polyaxon, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys from settings import configure configure() if __name__ == "__main__": from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
#!/usr/bin/env python import sys from os.path import dirname, abspath from django.conf import settings if not settings.configured: settings.configure( DATABASE_ENGINE='sqlite3', # HACK: this fixes our threaded runserver remote tests # TEST_DATABASE_NAME='test_sentry', INSTALLED_APPS=[ 'django.contrib.auth', 'django.contrib.admin', 'django.contrib.sessions', 'django.contrib.sites', # Included to fix Disqus' test Django which solves IntegrityMessage case 'django.contrib.contenttypes', 'nexus', ], ROOT_URLCONF='', DEBUG=False, ) from django.test.simple import DjangoTestSuiteRunner test_runner = DjangoTestSuiteRunner(verbosity=2, interactive=True) # from south.management.commands import patch_for_test_db_setup
import django from django.conf import settings if len(sys.argv) > 1 and 'postgres' in sys.argv: sys.argv.remove('postgres') db_engine = 'django.db.backends.postgresql_psycopg2' db_name = 'test_main' else: db_engine = 'django.db.backends.sqlite3' db_name = '' if not settings.configured: settings.configure( DATABASES=dict(default=dict(ENGINE=db_engine, NAME=db_name)), INSTALLED_APPS=[ 'django.contrib.contenttypes', 'genericm2m', 'genericm2m.genericm2m_tests', ], ) from django.test.utils import get_runner def runtests(*test_args): if not test_args: if sys.version_info[0] > 2: test_args = ['genericm2m.genericm2m_tests'] else: test_args = ["genericm2m_tests"] parent = dirname(abspath(__file__)) sys.path.insert(0, parent)
return self.success_url else: return reverse(self.success_view_name) class SubmitFAQThanks(TemplateView): template_name = "faq/submit_thanks.html" ########NEW FILE######## __FILENAME__ = _testrunner """ Test support harness to make setup.py test work. """ import sys from django.conf import settings settings.configure( DATABASES = { 'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory;'} }, INSTALLED_APPS = ['django.contrib.auth', 'django.contrib.contenttypes', 'faq'], ROOT_URLCONF = 'faq.urls', ) def runtests(): import django.test.utils runner_class = django.test.utils.get_runner(settings) test_runner = runner_class(verbosity=1, interactive=True) failures = test_runner.run_tests(['faq']) sys.exit(failures) ########NEW FILE########
import os.pathimport subprocessimport sysimport djangofrom django.conf import settings DATABASES = { 'postgresql': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'django_database_constraints', 'USER': '', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '', }, 'mysql': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'test_dummy', 'USER': '', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '', }, # can't figure out how to run sqlite3 with multithreaded support # during tests, so worthless trying this #'sqlite3': { # 'ENGINE': 'django.db.backends.sqlite3', # 'TEST_NAME': os.path.join(os.path.realpath(os.path.dirname(__file__)), 'test_sqlite_database'), #},} settings.configure( DEBUG=True, INSTALLED_APPS = [ 'django_database_constraints', ], DATABASES = { 'default': DATABASES['postgresql'], }, CONTEXT_PROCESSORS=[], TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [], } }, ])django.setup() # after we have some settingsfrom django.test.utils import override_settings def run_against(db): @override_settings(DATABASES = { 'default': DATABASES[db] }) def run_tests(): print("Running tests against %s database." % db) #from django.test.simple import DjangoTestSuiteRunner #test_runner = DjangoTestSuiteRunner(verbosity=1, failfast=False) from django.test.runner import DiscoverRunner test_runner = DiscoverRunner(verbosity=1, failfast=False) failures = test_runner.run_tests(['django_database_constraints', ]) if failures: #pragma no cover sys.exit(failures) run_tests() if len(sys.argv) == 1: #pragma no cover # we can't call run_against() multiple times and have it actually work # (possibly only since Django 1.6) for reasons I don't have time to # track down now (it's ignoring @override_settings on subsequent calls) failures = 0 for db in DATABASES.keys(): args = [ sys.executable, sys.argv[0], db ] rc = subprocess.call(args) failures += rc if failures != 0: print("\nTOTAL FAILURES: %i" % failures) sys.exit(failures)elif len(sys.argv) == 2: run_against(sys.argv[1])else: #pragma: no cover sys.stderr.write("Cannot run against multiple databases in one run.\n") sys.exit(100)
#!/usr/bin/env python # coding: utf-8 from __future__ import unicode_literals import sys from settings import configure if __name__ == '__main__': configure() from django.test.runner import DiscoverRunner test_runner = DiscoverRunner() failures = test_runner.run_tests(['cachalot.tests']) if failures: sys.exit(failures)