Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_ListOf():
assert ListOf(str)("") == []
assert ListOf(str)("foo") == ["foo"]
assert ListOf(bool)("t,f") == [True, False]
assert ListOf(int)("1,2,3") == [1, 2, 3]
assert ListOf(int, delimiter=":")("1:2") == [1, 2]
def test_ListOf_error():
config = ConfigManager.from_dict({"bools": "t,f,badbool"})
with pytest.raises(InvalidValueError) as exc_info:
config("bools", parser=ListOf(bool))
assert (
str(exc_info.value) == 'ValueError: "badbool" is not a valid bool value\n'
"namespace=None key=bools requires a value parseable by "
def test_ListOf():
assert ListOf(str)("") == []
assert ListOf(str)("foo") == ["foo"]
assert ListOf(bool)("t,f") == [True, False]
assert ListOf(int)("1,2,3") == [1, 2, 3]
assert ListOf(int, delimiter=":")("1:2") == [1, 2]
class Foo(object):
@classmethod
def parse_foo_class(cls, value):
pass
def parse_foo_instance(self, value):
pass
class ComponentOptionParser(RequiredConfigMixin):
required_config = ConfigOptions()
required_config.add_option("user_builtin", parser=int)
required_config.add_option("user_parse_class", parser=parse_class)
required_config.add_option("user_listof", parser=ListOf(str))
required_config.add_option("user_class_method", parser=Foo.parse_foo_class)
required_config.add_option("user_instance_method", parser=Foo().parse_foo_instance)
def test_option_parser(tmpdir):
rst = dedent(
"""\
.. autocomponent:: test_sphinxext.ComponentOptionParser
"""
)
assert parse(tmpdir, rst) == dedent(
"""\
component test_sphinxext.ComponentOptionParser
def test_ListOf():
assert ListOf(str)("") == []
assert ListOf(str)("foo") == ["foo"]
assert ListOf(bool)("t,f") == [True, False]
assert ListOf(int)("1,2,3") == [1, 2, 3]
assert ListOf(int, delimiter=":")("1:2") == [1, 2]
def test_ListOf():
assert ListOf(str)("") == []
assert ListOf(str)("foo") == ["foo"]
assert ListOf(bool)("t,f") == [True, False]
assert ListOf(int)("1,2,3") == [1, 2, 3]
assert ListOf(int, delimiter=":")("1:2") == [1, 2]
def test_ListOf():
assert ListOf(str)("") == []
assert ListOf(str)("foo") == ["foo"]
assert ListOf(bool)("t,f") == [True, False]
assert ListOf(int)("1,2,3") == [1, 2, 3]
assert ListOf(int, delimiter=":")("1:2") == [1, 2]
def get_params(cls) -> Dict[str, Any]:
return {name: value.__get__(cls, type(cls)) for name, value in cls.__dict__.items() if isinstance(value, Param)}
@classmethod
def log_params(cls):
from ebonite.utils.log import logger
logger.debug('%s environment:', cls.__name__)
for name, value in cls.get_params().items():
logger.debug('%s: %s', name, value)
class Core(Config):
DEBUG = Param('debug', default='false', doc='turn debug on', parser=bool)
ADDITIONAL_EXTENSIONS = Param('extensions', default='',
doc='comma-separated list of additional ebonite extensions to load',
parser=ListOf(str),
raise_error=False)
AUTO_IMPORT_EXTENSIONS = Param('auto_import_extensions', default='true',
doc='Set to true to automatically load available extensions on ebonite import',
parser=bool)
RUNTIME = Param('runtime', default='false', doc='is this instance a runtime', parser=bool)
class Logging(Config):
LOG_LEVEL = Param('log_level', default='INFO' if not Core.DEBUG else 'DEBUG',
doc='Logging level for ebonite',
parser=str)
class Runtime(Config):
SERVER = Param('server', doc='server for runtime')
LOADER = Param('loader', doc='interface loader for runtime')
])
# Build paths inside the project like this: path(...)
BASE_DIR = str(ROOT_PATH)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default='false', parser=bool)
ALLOWED_HOSTS = config('ALLOWED_HOSTS', parser=ListOf(str), default='localhost')
ENFORCE_HOSTNAME = config('ENFORCE_HOSTNAME', parser=ListOf(str), raise_error=False)
SITE_TITLE = config('SITE_TITLE', default='Standup')
# Application definition
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_jinja',
'django_jinja.contrib._humanize',
'django_jinja_markdown',
'mozilla_django_oidc',