当前位置: 首页>>代码示例>>Python>>正文


Python environ.Env类代码示例

本文整理汇总了Python中environ.Env的典型用法代码示例。如果您正苦于以下问题:Python Env类的具体用法?Python Env怎么用?Python Env使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Env类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: FileEnvTests

class FileEnvTests(EnvTests):

    def setUp(self):
        self.env = Env()
        self._orig_environ = os.environ
        os.environ = {}
        file_path = Path(__file__, is_file=True)('test_env.txt')
        self.env.read_env(file_path, PATH_VAR=Path(__file__, is_file=True).__root__)
开发者ID:AliLozano,项目名称:django-environ,代码行数:8,代码来源:test.py

示例2: test_database_options_parsing

    def test_database_options_parsing(self):
        url = 'postgres://user:[email protected]:1234/dbname?conn_max_age=600'
        url = Env.db_url_config(url)
        self.assertEqual(url['CONN_MAX_AGE'], 600)

        url = 'mysql://user:[email protected]:1234/dbname?init_command=SET storage_engine=INNODB'
        url = Env.db_url_config(url)
        self.assertEqual(url['OPTIONS'], {
            'init_command': 'SET storage_engine=INNODB',
        })
开发者ID:AliLozano,项目名称:django-environ,代码行数:10,代码来源:test.py

示例3: test_base_options_parsing

    def test_base_options_parsing(self):
        url = 'memcache://127.0.0.1:11211/?timeout=0&key_prefix=cache_&key_function=foo.get_key&version=1'
        url = Env.cache_url_config(url)

        self.assertEqual(url['KEY_PREFIX'], 'cache_')
        self.assertEqual(url['KEY_FUNCTION'], 'foo.get_key')
        self.assertEqual(url['TIMEOUT'], 0)
        self.assertEqual(url['VERSION'], 1)

        url = 'redis://127.0.0.1:6379/?timeout=None'
        url = Env.cache_url_config(url)

        self.assertEqual(url['TIMEOUT'], None)
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:13,代码来源:test.py

示例4: test_common_args_parsing

    def test_common_args_parsing(self):
        excluded_indexes = 'myapp.indexes.A,myapp.indexes.B'
        include_spelling = 1
        batch_size = 100
        params = 'EXCLUDED_INDEXES=%s&INCLUDE_SPELLING=%s&BATCH_SIZE=%s' % (
            excluded_indexes,
            include_spelling,
            batch_size
        )
        for url in [
            self.solr_url,
            self.elasticsearch_url,
            self.whoosh_url,
            self.xapian_url,
            self.simple_url,
        ]:
            url = '?'.join([url, params])
            url = Env.search_url_config(url)

            self.assertTrue('EXCLUDED_INDEXES' in url.keys())
            self.assertTrue('myapp.indexes.A' in url['EXCLUDED_INDEXES'])
            self.assertTrue('myapp.indexes.B' in url['EXCLUDED_INDEXES'])
            self.assertTrue('INCLUDE_SPELLING'in url.keys())
            self.assertTrue(url['INCLUDE_SPELLING'])
            self.assertTrue('BATCH_SIZE' in url.keys())
            self.assertEqual(url['BATCH_SIZE'], 100)
开发者ID:AliLozano,项目名称:django-environ,代码行数:26,代码来源:test.py

示例5: test_database_options_parsing

    def test_database_options_parsing(self):
        url = 'postgres://user:[email protected]:1234/dbname?conn_max_age=600'
        url = Env.db_url_config(url)
        self.assertEqual(url['CONN_MAX_AGE'], 600)

        url = 'postgres://user:[email protected]:1234/dbname?conn_max_age=None&autocommit=True&atomic_requests=False'
        url = Env.db_url_config(url)
        self.assertEqual(url['CONN_MAX_AGE'], None)
        self.assertEqual(url['AUTOCOMMIT'], True)
        self.assertEqual(url['ATOMIC_REQUESTS'], False)

        url = 'mysql://user:[email protected]:1234/dbname?init_command=SET storage_engine=INNODB'
        url = Env.db_url_config(url)
        self.assertEqual(url['OPTIONS'], {
            'init_command': 'SET storage_engine=INNODB',
        })
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:16,代码来源:test.py

示例6: test_postgres_parsing_unix_domain_socket

    def test_postgres_parsing_unix_domain_socket(self):
        url = 'postgres:////var/run/postgresql/db'
        url = Env.db_url_config(url)

        self.assertEqual(url['ENGINE'], DJANGO_POSTGRES)
        self.assertEqual(url['NAME'], 'db')
        self.assertEqual(url['HOST'], '/var/run/postgresql')
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:7,代码来源:test.py

示例7: test_memory_sqlite_url_warns_about_netloc

 def test_memory_sqlite_url_warns_about_netloc(self):
     url = 'sqlite://missing-slash-path'
     with warnings.catch_warnings(record=True) as w:
         url = Env.db_url_config(url)
         self.assertEqual(url['ENGINE'], 'django.db.backends.sqlite3')
         self.assertEqual(url['NAME'], ':memory:')
         self.assertEqual(len(w), 1)
         self.assertTrue(issubclass(w[0].category, UserWarning))
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:8,代码来源:test.py

示例8: test_redis_parsing

    def test_redis_parsing(self):
        url = 'rediscache://127.0.0.1:6379:1?client_class=django_redis.client.DefaultClient&password=secret'
        url = Env.cache_url_config(url)

        self.assertEqual(url['BACKEND'], 'django_redis.cache.RedisCache')
        self.assertEqual(url['LOCATION'], '127.0.0.1:6379:1')
        self.assertEqual(url['OPTIONS'], {
            'CLIENT_CLASS': 'django_redis.client.DefaultClient',
            'PASSWORD': 'secret',
        })
开发者ID:AliLozano,项目名称:django-environ,代码行数:10,代码来源:test.py

示例9: test_database_ldap_url

    def test_database_ldap_url(self):
        url = 'ldap://cn=admin,dc=nodomain,dc=org:[email protected]/'
        url = Env.db_url_config(url)

        self.assertEqual(url['ENGINE'], 'ldapdb.backends.ldap')
        self.assertEqual(url['HOST'], 'ldap.nodomain.org')
        self.assertEqual(url['PORT'], None)
        self.assertEqual(url['NAME'], 'ldap://ldap.nodomain.org')
        self.assertEqual(url['USER'], 'cn=admin,dc=nodomain,dc=org')
        self.assertEqual(url['PASSWORD'], 'some_secret_password')
开发者ID:AliLozano,项目名称:django-environ,代码行数:10,代码来源:test.py

示例10: test_cleardb_parsing

    def test_cleardb_parsing(self):
        url = 'mysql://bea6eb025ca0d8:[email protected]/heroku_97681db3eff7580?reconnect=true'
        url = Env.db_url_config(url)

        self.assertEqual(url['ENGINE'], 'django.db.backends.mysql')
        self.assertEqual(url['NAME'], 'heroku_97681db3eff7580')
        self.assertEqual(url['HOST'], 'us-cdbr-east.cleardb.com')
        self.assertEqual(url['USER'], 'bea6eb025ca0d8')
        self.assertEqual(url['PASSWORD'], '69772142')
        self.assertEqual(url['PORT'], None)
开发者ID:AliLozano,项目名称:django-environ,代码行数:10,代码来源:test.py

示例11: test_redis_multi_location_parsing

    def test_redis_multi_location_parsing(self):
        url = 'rediscache://host1:6379,host2:6379,host3:9999/1'
        url = Env.cache_url_config(url)

        self.assertEqual(url['BACKEND'], REDIS_DRIVER)
        self.assertEqual(url['LOCATION'], [
            'redis://host1:6379/1',
            'redis://host2:6379/1',
            'redis://host3:9999/1',
        ])
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:10,代码来源:test.py

示例12: test_mysql_gis_parsing

    def test_mysql_gis_parsing(self):
        url = 'mysqlgis://uf07k1i6d8ia0v:[email protected]:5431/d8r82722r2kuvn'
        url = Env.db_url_config(url)

        self.assertEqual(url['ENGINE'], 'django.contrib.gis.db.backends.mysql')
        self.assertEqual(url['NAME'], 'd8r82722r2kuvn')
        self.assertEqual(url['HOST'], 'ec2-107-21-253-135.compute-1.amazonaws.com')
        self.assertEqual(url['USER'], 'uf07k1i6d8ia0v')
        self.assertEqual(url['PASSWORD'], 'wegauwhgeuioweg')
        self.assertEqual(url['PORT'], 5431)
开发者ID:AliLozano,项目名称:django-environ,代码行数:10,代码来源:test.py

示例13: test_postgres_parsing

    def test_postgres_parsing(self):
        url = 'postgres://uf07k1i6d8ia0v:[email protected]:5431/d8r82722r2kuvn'
        url = Env.db_url_config(url)

        self.assertEqual(url['ENGINE'], DJANGO_POSTGRES)
        self.assertEqual(url['NAME'], 'd8r82722r2kuvn')
        self.assertEqual(url['HOST'], 'ec2-107-21-253-135.compute-1.amazonaws.com')
        self.assertEqual(url['USER'], 'uf07k1i6d8ia0v')
        self.assertEqual(url['PASSWORD'], 'wegauwhgeuioweg')
        self.assertEqual(url['PORT'], 5431)
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:10,代码来源:test.py

示例14: test_smtp_parsing

    def test_smtp_parsing(self):
        url = 'smtps://[email protected]:[email protected]:587'
        url = Env.email_url_config(url)

        self.assertEqual(url['EMAIL_BACKEND'], 'django.core.mail.backends.smtp.EmailBackend')
        self.assertEqual(url['EMAIL_HOST'], 'smtp.example.com')
        self.assertEqual(url['EMAIL_HOST_PASSWORD'], 'password')
        self.assertEqual(url['EMAIL_HOST_USER'], '[email protected]')
        self.assertEqual(url['EMAIL_PORT'], 587)
        self.assertEqual(url['EMAIL_USE_TLS'], True)
开发者ID:AliLozano,项目名称:django-environ,代码行数:10,代码来源:test.py

示例15: test_xapian_parsing

    def test_xapian_parsing(self):
        flags = 'myflags'
        url = '%s?FLAGS=%s' % (self.xapian_url, flags)
        url = Env.search_url_config(url)

        self.assertEqual(url['ENGINE'], 'haystack.backends.xapian_backend.XapianEngine')
        self.assertTrue('PATH' in url.keys())
        self.assertEqual(url['PATH'], '/home/search/xapian_index')
        self.assertTrue('FLAGS' in url.keys())
        self.assertEqual(url['FLAGS'], flags)
        self.assertTrue('INDEX_NAME' not in url)
开发者ID:AliLozano,项目名称:django-environ,代码行数:11,代码来源:test.py


注:本文中的environ.Env类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。