本文整理汇总了Python中napalm_base.base.NetworkDriver方法的典型用法代码示例。如果您正苦于以下问题:Python base.NetworkDriver方法的具体用法?Python base.NetworkDriver怎么用?Python base.NetworkDriver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类napalm_base.base
的用法示例。
在下文中一共展示了base.NetworkDriver方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mocked_method
# 需要导入模块: from napalm_base import base [as 别名]
# 或者: from napalm_base.base import NetworkDriver [as 别名]
def mocked_method(path, name, count):
parent_method = getattr(NetworkDriver, name)
parent_method_args = inspect.getargspec(parent_method)
modifier = 0 if 'self' not in parent_method_args.args else 1
def _mocked_method(*args, **kwargs):
# Check len(args)
if len(args) + len(kwargs) + modifier > len(parent_method_args.args):
raise TypeError(
"{}: expected at most {} arguments, got {}".format(
name, len(parent_method_args.args), len(args) + modifier))
# Check kwargs
unexpected = [x for x in kwargs if x not in parent_method_args.args]
if unexpected:
raise TypeError("{} got an unexpected keyword argument '{}'".format(name,
unexpected[0]))
return mocked_data(path, name, count)
return _mocked_method
示例2: test_get_network_driver
# 需要导入模块: from napalm_base import base [as 别名]
# 或者: from napalm_base.base import NetworkDriver [as 别名]
def test_get_network_driver(self, driver):
"""Check that we can get the desired driver and is instance of NetworkDriver."""
self.assertTrue(issubclass(get_network_driver(driver), NetworkDriver))
示例3: setUp
# 需要导入模块: from napalm_base import base [as 别名]
# 或者: from napalm_base.base import NetworkDriver [as 别名]
def setUp(self):
class FakeThing(NetworkDriver):
def __init__(self):
pass
self.device = FakeThing()