本文整理汇总了Python中syntaxnet.util.registry_test_base方法的典型用法代码示例。如果您正苦于以下问题:Python util.registry_test_base方法的具体用法?Python util.registry_test_base怎么用?Python util.registry_test_base使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类syntaxnet.util
的用法示例。
在下文中一共展示了util.registry_test_base方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCanCreateWithRelativePath
# 需要导入模块: from syntaxnet import util [as 别名]
# 或者: from syntaxnet.util import registry_test_base [as 别名]
def testCanCreateWithRelativePath(self):
"""Tests that Create can create the Impl subclass using a relative path."""
for name in [
PATH + 'registry_test_impl.Impl',
'syntaxnet.util.registry_test_impl.Impl',
'util.registry_test_impl.Impl',
'registry_test_impl.Impl'
]:
value = 'created via %s' % name
try:
impl = registry_test_base.Base.Create(name, value)
except ValueError:
self.fail('Create raised ValueError: %s' % traceback.format_exc())
self.assertTrue(impl is not None)
self.assertEqual(value, impl.Get())
示例2: testCanCreateImpl
# 需要导入模块: from syntaxnet import util [as 别名]
# 或者: from syntaxnet.util import registry_test_base [as 别名]
def testCanCreateImpl(self):
"""Tests that Create can create the Impl subclass."""
try:
impl = registry_test_base.Base.Create(PATH + 'registry_test_impl.Impl',
'hello world')
except ValueError:
self.fail('Create raised ValueError: %s' % traceback.format_exc())
self.assertEqual('hello world', impl.Get())
示例3: testCanCreateByAlias
# 需要导入模块: from syntaxnet import util [as 别名]
# 或者: from syntaxnet.util import registry_test_base [as 别名]
def testCanCreateByAlias(self):
"""Tests that Create can create an Impl subclass via Alias."""
try:
impl = registry_test_base.Base.Create(PATH + 'registry_test_impl.Alias',
'hello world')
except ValueError:
self.fail('Create raised ValueError: %s' % traceback.format_exc())
self.assertEqual('hello world', impl.Get())
示例4: testCannotCreateNonSubclass
# 需要导入模块: from syntaxnet import util [as 别名]
# 或者: from syntaxnet.util import registry_test_base [as 别名]
def testCannotCreateNonSubclass(self):
"""Tests that Create fails if the class is not a subclass of Base."""
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create(PATH + 'registry_test_impl.NonSubclass',
'hello world')
示例5: testCannotCreateNonClass
# 需要导入模块: from syntaxnet import util [as 别名]
# 或者: from syntaxnet.util import registry_test_base [as 别名]
def testCannotCreateNonClass(self):
"""Tests that Create fails if the name does not identify a class."""
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create(PATH + 'registry_test_impl.variable',
'hello world')
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create(PATH + 'registry_test_impl.Function',
'hello world')
示例6: testCannotCreateMissingClass
# 需要导入模块: from syntaxnet import util [as 别名]
# 或者: from syntaxnet.util import registry_test_base [as 别名]
def testCannotCreateMissingClass(self):
"""Tests that Create fails if the class does not exist in the module."""
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create(PATH + 'registry_test_impl.MissingClass',
'hello world')
示例7: testCannotCreateMissingPackage
# 需要导入模块: from syntaxnet import util [as 别名]
# 或者: from syntaxnet.util import registry_test_base [as 别名]
def testCannotCreateMissingPackage(self):
"""Tests that Create fails if the package does not exist."""
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create('missing.package.path.module.SomeClass',
'hello world')
示例8: testCannotCreateMalformedType
# 需要导入模块: from syntaxnet import util [as 别名]
# 或者: from syntaxnet.util import registry_test_base [as 别名]
def testCannotCreateMalformedType(self):
"""Tests that Create fails on malformed type names."""
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create('oneword', 'hello world')
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create('hyphen-ated', 'hello world')
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create('has space', 'hello world')
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create(' ', 'hello world')
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create('', 'hello world')
示例9: testCannotResolveRelativeName
# 需要导入模块: from syntaxnet import util [as 别名]
# 或者: from syntaxnet.util import registry_test_base [as 别名]
def testCannotResolveRelativeName(self):
"""Tests that Create fails if a relative path cannot be resolved."""
for name in [
'nlp.saft.opensource.syntaxnet.util.registry_test_base.Impl',
'saft.bad.registry_test_impl.Impl', 'missing.registry_test_impl.Impl',
'registry_test_impl.Bad', 'Impl'
]:
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create(name, 'hello world')
示例10: testCannotResolveRelativeName
# 需要导入模块: from syntaxnet import util [as 别名]
# 或者: from syntaxnet.util import registry_test_base [as 别名]
def testCannotResolveRelativeName(self):
"""Tests that Create fails if a relative path cannot be resolved."""
for name in [
'bad.syntaxnet.util.registry_test_base.Impl',
'syntaxnet.bad.registry_test_impl.Impl',
'missing.registry_test_impl.Impl',
'registry_test_impl.Bad',
'Impl'
]:
with self.assertRaisesRegexp(ValueError, 'Failed to create'):
registry_test_base.Base.Create(name, 'hello world')