本文整理汇总了Python中mozpack.copier.FileRegistry.required_directories方法的典型用法代码示例。如果您正苦于以下问题:Python FileRegistry.required_directories方法的具体用法?Python FileRegistry.required_directories怎么用?Python FileRegistry.required_directories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozpack.copier.FileRegistry
的用法示例。
在下文中一共展示了FileRegistry.required_directories方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestFileRegistry
# 需要导入模块: from mozpack.copier import FileRegistry [as 别名]
# 或者: from mozpack.copier.FileRegistry import required_directories [as 别名]
class TestFileRegistry(BaseTestFileRegistry, unittest.TestCase):
def test_partial_paths(self):
cases = {
'foo/bar/baz/zot': ['foo/bar/baz', 'foo/bar', 'foo'],
'foo/bar': ['foo'],
'bar': [],
}
reg = FileRegistry()
for path, parts in cases.iteritems():
self.assertEqual(reg._partial_paths(path), parts)
def test_file_registry(self):
self.do_test_file_registry(FileRegistry())
def test_registry_paths(self):
self.do_test_registry_paths(FileRegistry())
def test_required_directories(self):
self.registry = FileRegistry()
self.registry.add('foo', GeneratedFile('foo'))
self.assertEqual(self.registry.required_directories(), set())
self.registry.add('bar/baz', GeneratedFile('barbaz'))
self.assertEqual(self.registry.required_directories(), {'bar'})
self.registry.add('bar/zot', GeneratedFile('barzot'))
self.assertEqual(self.registry.required_directories(), {'bar'})
self.registry.add('bar/zap/zot', GeneratedFile('barzapzot'))
self.assertEqual(self.registry.required_directories(), {'bar', 'bar/zap'})
self.registry.remove('bar/zap/zot')
self.assertEqual(self.registry.required_directories(), {'bar'})
self.registry.remove('bar/baz')
self.assertEqual(self.registry.required_directories(), {'bar'})
self.registry.remove('bar/zot')
self.assertEqual(self.registry.required_directories(), set())
self.registry.add('x/y/z', GeneratedFile('xyz'))
self.assertEqual(self.registry.required_directories(), {'x', 'x/y'})
示例2: TestFileRegistry
# 需要导入模块: from mozpack.copier import FileRegistry [as 别名]
# 或者: from mozpack.copier.FileRegistry import required_directories [as 别名]
class TestFileRegistry(BaseTestFileRegistry, unittest.TestCase):
def test_partial_paths(self):
cases = {"foo/bar/baz/zot": ["foo/bar/baz", "foo/bar", "foo"], "foo/bar": ["foo"], "bar": []}
reg = FileRegistry()
for path, parts in cases.iteritems():
self.assertEqual(reg._partial_paths(path), parts)
def test_file_registry(self):
self.do_test_file_registry(FileRegistry())
def test_registry_paths(self):
self.do_test_registry_paths(FileRegistry())
def test_required_directories(self):
self.registry = FileRegistry()
self.registry.add("foo", GeneratedFile("foo"))
self.assertEqual(self.registry.required_directories(), set())
self.registry.add("bar/baz", GeneratedFile("barbaz"))
self.assertEqual(self.registry.required_directories(), {"bar"})
self.registry.add("bar/zot", GeneratedFile("barzot"))
self.assertEqual(self.registry.required_directories(), {"bar"})
self.registry.add("bar/zap/zot", GeneratedFile("barzapzot"))
self.assertEqual(self.registry.required_directories(), {"bar", "bar/zap"})
self.registry.remove("bar/zap/zot")
self.assertEqual(self.registry.required_directories(), {"bar"})
self.registry.remove("bar/baz")
self.assertEqual(self.registry.required_directories(), {"bar"})
self.registry.remove("bar/zot")
self.assertEqual(self.registry.required_directories(), set())
self.registry.add("x/y/z", GeneratedFile("xyz"))
self.assertEqual(self.registry.required_directories(), {"x", "x/y"})
示例3: TestFileRegistry
# 需要导入模块: from mozpack.copier import FileRegistry [as 别名]
# 或者: from mozpack.copier.FileRegistry import required_directories [as 别名]
class TestFileRegistry(MatchTestTemplate, unittest.TestCase):
def add(self, path):
self.registry.add(path, GeneratedFile(path))
def do_check(self, pattern, result):
self.checked = True
if result:
self.assertTrue(self.registry.contains(pattern))
else:
self.assertFalse(self.registry.contains(pattern))
self.assertEqual(self.registry.match(pattern), result)
def test_file_registry(self):
self.registry = FileRegistry()
self.registry.add('foo', GeneratedFile('foo'))
bar = GeneratedFile('bar')
self.registry.add('bar', bar)
self.assertEqual(self.registry.paths(), ['foo', 'bar'])
self.assertEqual(self.registry['bar'], bar)
self.assertRaises(ErrorMessage, self.registry.add, 'foo',
GeneratedFile('foo2'))
self.assertRaises(ErrorMessage, self.registry.remove, 'qux')
self.assertRaises(ErrorMessage, self.registry.add, 'foo/bar',
GeneratedFile('foobar'))
self.assertRaises(ErrorMessage, self.registry.add, 'foo/bar/baz',
GeneratedFile('foobar'))
self.assertEqual(self.registry.paths(), ['foo', 'bar'])
self.registry.remove('foo')
self.assertEqual(self.registry.paths(), ['bar'])
self.registry.remove('bar')
self.assertEqual(self.registry.paths(), [])
self.prepare_match_test()
self.do_match_test()
self.assertTrue(self.checked)
self.assertEqual(self.registry.paths(), [
'bar',
'foo/bar',
'foo/baz',
'foo/qux/1',
'foo/qux/bar',
'foo/qux/2/test',
'foo/qux/2/test2',
])
self.registry.remove('foo/qux')
self.assertEqual(self.registry.paths(), ['bar', 'foo/bar', 'foo/baz'])
self.registry.add('foo/qux', GeneratedFile('fooqux'))
self.assertEqual(self.registry.paths(), ['bar', 'foo/bar', 'foo/baz',
'foo/qux'])
self.registry.remove('foo/b*')
self.assertEqual(self.registry.paths(), ['bar', 'foo/qux'])
self.assertEqual([f for f, c in self.registry], ['bar', 'foo/qux'])
self.assertEqual(len(self.registry), 2)
self.add('foo/.foo')
self.assertTrue(self.registry.contains('foo/.foo'))
def test_registry_paths(self):
self.registry = FileRegistry()
# Can't add a file if it requires a directory in place of a
# file we also require.
self.registry.add('foo', GeneratedFile('foo'))
self.assertRaises(ErrorMessage, self.registry.add, 'foo/bar',
GeneratedFile('foobar'))
# Can't add a file if we already have a directory there.
self.registry.add('bar/baz', GeneratedFile('barbaz'))
self.assertRaises(ErrorMessage, self.registry.add, 'bar',
GeneratedFile('bar'))
# Bump the count of things that require bar/ to 2.
self.registry.add('bar/zot', GeneratedFile('barzot'))
self.assertRaises(ErrorMessage, self.registry.add, 'bar',
GeneratedFile('bar'))
# Drop the count of things that require bar/ to 1.
self.registry.remove('bar/baz')
self.assertRaises(ErrorMessage, self.registry.add, 'bar',
GeneratedFile('bar'))
# Drop the count of things that require bar/ to 0.
self.registry.remove('bar/zot')
self.registry.add('bar/zot', GeneratedFile('barzot'))
def test_required_directories(self):
self.registry = FileRegistry()
self.registry.add('foo', GeneratedFile('foo'))
self.assertEqual(self.registry.required_directories(), set())
self.registry.add('bar/baz', GeneratedFile('barbaz'))
#.........这里部分代码省略.........