当前位置: 首页>>代码示例>>Python>>正文


Python util.registry_test_base方法代码示例

本文整理汇总了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()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:registry_test.py

示例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()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:10,代码来源:registry_test.py

示例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()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:10,代码来源:registry_test.py

示例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') 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:7,代码来源:registry_test.py

示例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') 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:10,代码来源:registry_test.py

示例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') 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:7,代码来源:registry_test.py

示例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') 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:7,代码来源:registry_test.py

示例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') 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:14,代码来源:registry_test.py

示例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') 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:11,代码来源:registry_test.py

示例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') 
开发者ID:rky0930,项目名称:yolo_v2,代码行数:13,代码来源:registry_test.py


注:本文中的syntaxnet.util.registry_test_base方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。