本文整理匯總了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')