本文整理汇总了Python中fixtures.EnvironmentVariable方法的典型用法代码示例。如果您正苦于以下问题:Python fixtures.EnvironmentVariable方法的具体用法?Python fixtures.EnvironmentVariable怎么用?Python fixtures.EnvironmentVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fixtures
的用法示例。
在下文中一共展示了fixtures.EnvironmentVariable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def setUp(self):
super(SkipFileWrites, self).setUp()
self.temp_path = self.useFixture(fixtures.TempDir()).path
self.root_dir = os.path.abspath(os.path.curdir)
self.git_dir = os.path.join(self.root_dir, ".git")
if not os.path.exists(self.git_dir):
self.skipTest("%s is missing; skipping git-related checks"
% self.git_dir)
return
self.filename = os.path.join(self.temp_path, self.filename)
self.option_dict = dict()
if self.option_key is not None:
self.option_dict[self.option_key] = ('setup.cfg',
self.option_value)
self.useFixture(
fixtures.EnvironmentVariable(self.env_key, self.env_value))
示例2: setUp
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def setUp(self):
self.statsd = StatsdFixture()
self.useFixture(self.statsd)
# note, use 127.0.0.1 rather than localhost to avoid getting ipv6
# see: https://github.com/jsocol/pystatsd/issues/61
self.useFixture(
fixtures.EnvironmentVariable('STATSD_HOST', '127.0.0.1'))
self.useFixture(
fixtures.EnvironmentVariable('STATSD_PORT', str(self.statsd.port)))
self.add_info_on_exception('statsd_content', self.statsd.stats)
# Set up the above things before the super setup so that we have the
# environment variables set when the Connection is created.
super(TestStats, self).setUp()
self._registry = prometheus_client.CollectorRegistry()
self.cloud.config._collector_registry = self._registry
self.addOnException(self._add_prometheus_samples)
示例3: setUp
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def setUp(self):
super(TestVendorProfile, self).setUp()
# Create a temporary directory where our test config will live
# and insert it into the search path via OS_CLIENT_CONFIG_FILE.
config_dir = self.useFixture(fixtures.TempDir()).path
config_path = os.path.join(config_dir, "clouds.yaml")
public_clouds = os.path.join(config_dir, "clouds-public.yaml")
with open(config_path, "w") as conf:
conf.write(CLOUD_CONFIG)
with open(public_clouds, "w") as conf:
conf.write(PUBLIC_CLOUDS_YAML)
self.useFixture(fixtures.EnvironmentVariable(
"OS_CLIENT_CONFIG_FILE", config_path))
self.use_keystone_v2()
self.config = openstack.config.loader.OpenStackConfig(
vendor_files=[public_clouds])
示例4: setUp
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def setUp(self):
super(TestCase, self).setUp()
conf = copy.deepcopy(USER_CONF)
tdir = self.useFixture(fixtures.TempDir())
conf['cache']['path'] = tdir.path
self.cloud_yaml = _write_yaml(conf)
self.secure_yaml = _write_yaml(SECURE_CONF)
self.vendor_yaml = _write_yaml(VENDOR_CONF)
self.no_yaml = _write_yaml(NO_CONF)
# Isolate the test runs from the environment
# Do this as two loops because you can't modify the dict in a loop
# over the dict in 3.4
keys_to_isolate = []
for env in os.environ.keys():
if env.startswith('OS_'):
keys_to_isolate.append(env)
for env in keys_to_isolate:
self.useFixture(fixtures.EnvironmentVariable(env))
示例5: test_get_cloud_names
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def test_get_cloud_names(self):
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
secure_files=[self.no_yaml])
self.assertEqual(
['_test-cloud-domain-id_',
'_test-cloud-domain-scoped_',
'_test-cloud-int-project_',
'_test-cloud-networks_',
'_test-cloud_',
'_test-cloud_no_region',
'_test_cloud_hyphenated',
'_test_cloud_no_vendor',
'_test_cloud_regions',
],
sorted(c.get_cloud_names()))
c = config.OpenStackConfig(config_files=[self.no_yaml],
vendor_files=[self.no_yaml],
secure_files=[self.no_yaml])
for k in os.environ.keys():
if k.startswith('OS_'):
self.useFixture(fixtures.EnvironmentVariable(k))
c.get_one(cloud='defaults', validate=False)
self.assertEqual(['defaults'], sorted(c.get_cloud_names()))
示例6: setUp
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def setUp(self):
super(TestCase, self).setUp()
self.useFixture(fixtures.NestedTempfile())
conf = copy.deepcopy(USER_CONF)
tdir = self.useFixture(fixtures.TempDir())
conf['cache']['path'] = tdir.path
self.cloud_yaml = _write_yaml(conf)
self.secure_yaml = _write_yaml(SECURE_CONF)
self.vendor_yaml = _write_yaml(VENDOR_CONF)
self.no_yaml = _write_yaml(NO_CONF)
self.useFixture(fixtures.MonkeyPatch(
'os_client_config.__version__', '1.2.3'))
self.useFixture(fixtures.MonkeyPatch(
'openstack.version.__version__', '3.4.5'))
# Isolate the test runs from the environment
# Do this as two loops because you can't modify the dict in a loop
# over the dict in 3.4
keys_to_isolate = []
for env in os.environ.keys():
if env.startswith('OS_'):
keys_to_isolate.append(env)
for env in keys_to_isolate:
self.useFixture(fixtures.EnvironmentVariable(env))
示例7: test_get_cloud_names
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def test_get_cloud_names(self):
c = config.OpenStackConfig(config_files=[self.cloud_yaml],
secure_files=[self.no_yaml])
self.assertEqual(
['_test-cloud-domain-id_',
'_test-cloud-domain-scoped_',
'_test-cloud-int-project_',
'_test-cloud-networks_',
'_test-cloud_',
'_test-cloud_no_region',
'_test_cloud_hyphenated',
'_test_cloud_no_vendor',
'_test_cloud_regions',
],
sorted(c.get_cloud_names()))
c = config.OpenStackConfig(config_files=[self.no_yaml],
vendor_files=[self.no_yaml],
secure_files=[self.no_yaml])
for k in os.environ.keys():
if k.startswith('OS_'):
self.useFixture(fixtures.EnvironmentVariable(k))
c.get_one_cloud(cloud='defaults', validate=False)
self.assertEqual(['defaults'], sorted(c.get_cloud_names()))
示例8: test_only_title
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def test_only_title(self):
self.useFixture(fixtures.EnvironmentVariable("EDITOR", "cat"))
tempdir = self.useFixture(fixtures.TempDir()).path
os.chdir(tempdir)
self.assertEqual(
("foobar", "something\nawesome"),
gpr.parse_pr_message("foobar\nsomething\nawesome"),
)
self.assertEqual(
("foobar", "something\nawesome\n"),
gpr.parse_pr_message("foobar\nsomething\nawesome\n"),
)
self.assertEqual(
("foobar", "something\nawesome\n"),
gpr.parse_pr_message("foobar\n\nsomething\nawesome\n"),
)
示例9: test_parse_requirements_override_with_env
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def test_parse_requirements_override_with_env(self):
with open(self.tmp_file, 'w') as fh:
fh.write("foo\nbar")
self.useFixture(
fixtures.EnvironmentVariable('PBR_REQUIREMENTS_FILES',
self.tmp_file))
self.assertEqual(['foo', 'bar'],
packaging.parse_requirements())
示例10: test_parse_requirements_override_with_env_multiple_files
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def test_parse_requirements_override_with_env_multiple_files(self):
with open(self.tmp_file, 'w') as fh:
fh.write("foo\nbar")
self.useFixture(
fixtures.EnvironmentVariable('PBR_REQUIREMENTS_FILES',
"no-such-file," + self.tmp_file))
self.assertEqual(['foo', 'bar'],
packaging.parse_requirements())
示例11: test_console_script_install
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def test_console_script_install(self):
"""Test that we install a non-pkg-resources console script."""
if os.name == 'nt':
self.skipTest('Windows support is passthrough')
stdout, _, return_code = self.run_setup(
'install_scripts', '--install-dir=%s' % self.temp_dir)
self.useFixture(
fixtures.EnvironmentVariable('PYTHONPATH', '.'))
self.check_script_install(stdout)
示例12: setUp
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def setUp(self):
# Integration tests need a higher default - big repos can be slow to
# clone, particularly under guest load.
env = fixtures.EnvironmentVariable(
'OS_TEST_TIMEOUT', os.environ.get('OS_TEST_TIMEOUT', '600'))
with env:
super(TestIntegration, self).setUp()
base._config_git()
示例13: setUp
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def setUp(self):
"""Run before each test method to initialize test environment."""
# Ensure BaseTestCase's ConfigureLogging fixture is disabled since
# we're using the one from Nova (StandardLogging).
with fixtures.EnvironmentVariable('OS_LOG_CAPTURE', '0'):
super(NoDBTestCase, self).setUp()
self.useFixture(mock_fixture.MockAutospecFixture())
self.useFixture(log_fixture.get_logging_handle_error_fixture())
self.useFixture(nova_fixtures.StandardLogging())
self.useFixture(conf_fixture.ConfFixture(CONF))
# NOTE(blk-u): WarningsFixture must be after the Database fixture
# because sqlalchemy-migrate messes with the warnings filters.
self.useFixture(nova_fixtures.WarningsFixture())
self.addCleanup(self._clear_attrs)
self.policy = self.useFixture(policy_fixture.PolicyFixture())
self.useFixture(nova_fixtures.PoisonFunctions())
if self.MOCK_TOOZ:
self.patch('compute_hyperv.nova.coordination.Coordinator.start')
self.patch('compute_hyperv.nova.coordination.Coordinator.stop')
self.patch('compute_hyperv.nova.coordination.Coordinator.get_lock')
示例14: putenv
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def putenv(self, key, value, raw=False):
if not raw:
key = self.env_prefix + "_" + key
self.env[key] = value
return self.useFixture(fixtures.EnvironmentVariable(key, value))
示例15: test_non_existing_command
# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import EnvironmentVariable [as 别名]
def test_non_existing_command(self):
# Keep PATH to just the one set by tox to run pifpaf
self.useFixture(fixtures.EnvironmentVariable(
"PATH", os.getenv("PATH").split(":")[0]))
c = subprocess.Popen(["pifpaf", "run", "memcached"],
bufsize=0,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE)
(stdout, stderr) = c.communicate()
self.assertEqual(1, c.wait())
self.assertIn(
b"ERROR [pifpaf] Unable to run command "
b"`memcached -p 11212': [Errno 2] No such file or directory",
stderr)