本文整理汇总了Python中txclib.project.Project._get_option方法的典型用法代码示例。如果您正苦于以下问题:Python Project._get_option方法的具体用法?Python Project._get_option怎么用?Python Project._get_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txclib.project.Project
的用法示例。
在下文中一共展示了Project._get_option方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestOptions
# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import _get_option [as 别名]
class TestOptions(unittest.TestCase):
"""Test the methods related to parsing the configuration file."""
def setUp(self):
self.p = Project(init=False)
def test_get_option(self):
"""Test _get_option method."""
with patch.object(self.p, 'get_resource_option') as rmock:
with patch.object(self.p, 'config', create=True) as cmock:
rmock.return_value = 'resource'
cmock.has_option.return_value = 'main'
cmock.get.return_value = 'main'
self.assertEqual(self.p._get_option(None, None), 'resource')
rmock.return_value = None
cmock.has_option.return_value = 'main'
cmock.get.return_value = 'main'
self.assertEqual(self.p._get_option(None, None), 'main')
cmock.has_option.return_value = None
self.assertIs(self.p._get_option(None, None), None)
示例2: TestOptions
# 需要导入模块: from txclib.project import Project [as 别名]
# 或者: from txclib.project.Project import _get_option [as 别名]
class TestOptions(unittest.TestCase):
"""Test the methods related to parsing the configuration file."""
def setUp(self):
self.p = Project(init=False)
def test_get_option(self):
"""Test _get_option method."""
with contextlib.nested(
patch.object(self.p, "get_resource_option"), patch.object(self.p, "config", create=True)
) as (rmock, cmock):
rmock.return_value = "resource"
cmock.has_option.return_value = "main"
cmock.get.return_value = "main"
self.assertEqual(self.p._get_option(None, None), "resource")
rmock.return_value = None
cmock.has_option.return_value = "main"
cmock.get.return_value = "main"
self.assertEqual(self.p._get_option(None, None), "main")
cmock.has_option.return_value = None
self.assertIs(self.p._get_option(None, None), None)