本文整理汇总了Python中shared.create_dir函数的典型用法代码示例。如果您正苦于以下问题:Python create_dir函数的具体用法?Python create_dir怎么用?Python create_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_override
def test_override(self):
module_dir = shared.create_dir({'foo': 'bar'})
self.write_yaml('''\
cp module foo:
path: {}
imports:
foo: ./
''', module_dir)
override_dir = shared.create_dir({'foo': 'override'})
# Set the override.
run_peru_command(['override', 'add', 'foo', override_dir],
self.test_dir)
# Confirm that the override is configured.
output = run_peru_command(['override'], self.test_dir)
self.assertEqual(output, 'foo: {}\n'.format(override_dir))
# Make sure 'override list' gives the same output as 'override'.
output = run_peru_command(['override', 'list'], self.test_dir)
self.assertEqual(output, 'foo: {}\n'.format(override_dir))
# Run the sync and confirm that the override worked.
self.do_integration_test(['sync'], {'foo': 'override'})
# Delete the override.
run_peru_command(['override', 'delete', 'foo'], self.test_dir)
# Confirm that the override was deleted.
output = run_peru_command(['override'], self.test_dir)
self.assertEqual(output, '')
# Rerun the sync and confirm the original content is back.
self.do_integration_test(['sync'], {'foo': 'bar'})
示例2: test_override
def test_override(self):
module_dir = shared.create_dir({'foo': 'bar'})
self.write_yaml('''\
cp module foo:
path: {}
imports:
foo: ./
''', module_dir)
override_dir = shared.create_dir({'foo': 'override'})
# Set the override.
run_peru_command(['override', 'add', 'foo', override_dir],
self.test_dir)
# Confirm that the override is configured.
output = run_peru_command(['override'], self.test_dir)
self.assertEqual(output, 'foo: {}\n'.format(override_dir))
# Make sure 'override list' gives the same output as 'override'.
output = run_peru_command(['override', 'list'], self.test_dir)
self.assertEqual(output, 'foo: {}\n'.format(override_dir))
# Run the sync with --no-overrides and confirm nothing changes. Also
# check that there's no overrides-related output.
output = self.do_integration_test(['sync', '--no-overrides'],
{'foo': 'bar'})
self.assertNotIn('overrides', output)
# Now run the sync normally and confirm that the override worked. Also
# confirm that we mentioned the override in output.
output = self.do_integration_test(['sync'], {'foo': 'override'})
self.assertIn('overrides', output)
# Delete the override.
run_peru_command(['override', 'delete', 'foo'], self.test_dir)
# Confirm that the override was deleted.
output = run_peru_command(['override'], self.test_dir)
self.assertEqual(output, '')
# Rerun the sync and confirm the original content is back.
self.do_integration_test(['sync'], {'foo': 'bar'})
示例3: test_import_with_gitignore
def test_import_with_gitignore(self):
# Make sure our git imports don't get confused by .gitignore files.
new_content = {"fee/fi": "fo fum", ".gitignore": "fee/"}
new_tree = self.cache.import_tree(shared.create_dir(new_content))
export_dir = shared.create_dir()
self.cache.export_tree(new_tree, export_dir)
assert_contents(export_dir, new_content)
示例4: setUp
def setUp(self):
self.cache_dir = shared.create_dir()
self.cache = cache.Cache(self.cache_dir)
self.content = {'a': 'foo', 'b/c': 'bar'}
self.content_dir = shared.create_dir(self.content)
self.content_tree = self.cache.import_tree(self.content_dir)
self.entries = self.cache.ls_tree(self.content_tree, recursive=True)
示例5: test_identical_plugin_cache_fields
def test_identical_plugin_cache_fields(self):
# Plugins that use caching also need to avoid running in parallel, if
# their cache directories are the same. The noop_cache plugin (created
# for this test) uses the path field (but not the nonce field) in its
# plugin cache key. Check that these two modules are not fetched in
# parallel, even though their module fields aren't exactly the same.
foo = shared.create_dir()
peru_yaml = dedent('''\
imports:
foo1: ./
foo2: ./
noop_cache module foo1:
path: {}
# nonce is ignored, but it makes foo1 different from foo2 as
# far as the module cache is concerned
nonce: '1'
noop_cache module foo2:
path: {}
nonce: '2'
'''.format(foo, foo))
test_dir = shared.create_dir({'peru.yaml': peru_yaml})
shared.run_peru_command(['sync'], test_dir)
assert_parallel(1)
示例6: setUp
def setUp(self):
self.cache_dir = shared.create_dir()
self.cache = yield from cache.Cache(self.cache_dir)
self.content = {"a": "foo", "b/c": "bar"}
self.content_dir = shared.create_dir(self.content)
self.content_tree = yield from self.cache.import_tree(self.content_dir)
self.entries = yield from self.cache.ls_tree(self.content_tree, recursive=True)
示例7: test_import_with_gitignore
def test_import_with_gitignore(self):
# Make sure our git imports don't get confused by .gitignore files.
new_content = {'fee/fi': 'fo fum', '.gitignore': 'fee/'}
new_tree = yield from self.cache.import_tree(create_dir(new_content))
export_dir = create_dir()
yield from self.cache.export_tree(new_tree, export_dir)
assert_contents(export_dir, new_content)
示例8: test_keyval
def test_keyval(self):
root = shared.create_dir()
tmp_dir = shared.create_dir()
keyval = KeyVal(root, tmp_dir)
key = "mykey"
# keyval should be empty
self.assertFalse(key in keyval)
self.assertSetEqual(set(keyval), set())
# set a key
keyval[key] = "myval"
self.assertEqual(keyval[key], "myval")
self.assertTrue(key in keyval)
self.assertSetEqual(set(keyval), {key})
# overwrite the value
keyval[key] = "anotherval"
self.assertEqual(keyval[key], "anotherval")
# instantiate a second keyval on the same dir, should have same content
another_keyval = KeyVal(root, tmp_dir)
self.assertTrue(key in another_keyval)
self.assertEqual(another_keyval[key], "anotherval")
self.assertSetEqual(set(another_keyval), {key})
# test deletions
del keyval[key]
self.assertFalse(key in keyval)
self.assertFalse(key in another_keyval)
示例9: test_flags_override_vars
def test_flags_override_vars(self):
flag_cache_dir = shared.create_dir()
env_cache_dir = shared.create_dir()
shared.run_peru_command(['--cache-dir', flag_cache_dir, 'sync'],
self.cwd,
env={'PERU_CACHE_DIR': env_cache_dir})
self.assert_success(self.project_dir, self.state_dir, flag_cache_dir)
示例10: test_import_module_defined_in_another_module
def test_import_module_defined_in_another_module(self):
# Project B contains project A
dir_a = shared.create_dir({'afile': 'stuff'})
dir_b = shared.create_dir()
# Create the peru.yaml file for B.
self.write_yaml('''\
cp module a:
path: {}
''', dir_a, dir=dir_b)
# Now create the peru.yaml file in the actual test project.
self.write_yaml('''\
imports:
b.a: a_via_b/
cp module b:
path: {}
''', dir_b)
self.do_integration_test(['sync'], {'a_via_b/afile': 'stuff'})
# Test the error message from an invalid module.
self.write_yaml('''\
imports:
b.missing_module: some_path
cp module b:
path: {}
''', dir_b)
try:
self.do_integration_test(['sync'], {})
except peru.error.PrintableError as e:
assert 'b.missing_module' in e.message
else:
assert False, 'should throw invalid module error'
示例11: test_touched_file
def test_touched_file(self):
# Bumping the mtime on a file makes it appear dirty to `git
# diff-files`. However, when the index is refreshed with `git
# update-index`, the dirtiness should go away. This test guarantees
# that we do that refresh, both with and without a cached index file.
# Note that because the index file only has an mtime resolution of 1
# second, we have to artificially inflate the mtime to guarantee that
# the file will actually appear dirty.
export_dir = create_dir()
a_path = os.path.join(export_dir, 'a')
t = time.time()
def bump_mtime_one_minute():
nonlocal t
t += 60 # Add a whole minute to the mtime we set.
os.utime(a_path, (t, t))
# Do the first export.
yield from self.cache.export_tree(self.content_tree, export_dir)
# Touch a and rerun the export with no cached index.
bump_mtime_one_minute()
yield from self.cache.export_tree(
self.content_tree, export_dir, previous_tree=self.content_tree)
# Create a cached index file.
index_dir = create_dir()
index_file = os.path.join(index_dir, 'test_index_file')
yield from self.cache.export_tree(
self.content_tree, export_dir, previous_tree=self.content_tree,
previous_index_file=index_file)
# Finally, touch a again and rerun the export using the cached index.
bump_mtime_one_minute()
yield from self.cache.export_tree(
self.content_tree, export_dir, previous_tree=self.content_tree,
previous_index_file=index_file)
示例12: setUp
def setUp(self):
self.cache_dir = create_dir()
self.cache = Cache(self.cache_dir)
# These tests use this simple one-file tree as module contents.
content = {'a': 'a'}
content_dir = create_dir(content)
self.content_tree = self.cache.import_tree(content_dir)
示例13: setUp
async def setUp(self):
self.cache_dir = shared.create_dir()
self.cache = await cache.Cache(self.cache_dir)
# Include a leading colon to test that we prepend ./ to pathspecs.
self.content = {'a': 'foo', 'b/c': 'bar', COLON + 'd': 'baz'}
self.content_dir = shared.create_dir(self.content)
self.content_tree = await self.cache.import_tree(self.content_dir)
self.entries = await self.cache.ls_tree(
self.content_tree, recursive=True)
示例14: setUp
def setUp(self):
self.cache = peru.cache.Cache(shared.create_dir())
self.content = {
"a": "foo",
"b/c": "bar",
"b/d": "baz",
}
self.content_dir = shared.create_dir(self.content)
self.content_tree = self.cache.import_tree(self.content_dir)
示例15: setUp
async def setUp(self):
self.cache = await peru.cache.Cache(create_dir())
self.content = {
'a': 'foo',
'b/c': 'bar',
'b/d': 'baz',
}
self.content_dir = create_dir(self.content)
self.content_tree = await self.cache.import_tree(self.content_dir)