當前位置: 首頁>>代碼示例>>Python>>正文


Python ObjFactory.object_get_byval方法代碼示例

本文整理匯總了Python中misc_utils_objectfactory.ObjFactory.object_get_byval方法的典型用法代碼示例。如果您正苦於以下問題:Python ObjFactory.object_get_byval方法的具體用法?Python ObjFactory.object_get_byval怎麽用?Python ObjFactory.object_get_byval使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在misc_utils_objectfactory.ObjFactory的用法示例。


在下文中一共展示了ObjFactory.object_get_byval方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Test_ObjFrameworkGetByVal

# 需要導入模塊: from misc_utils_objectfactory import ObjFactory [as 別名]
# 或者: from misc_utils_objectfactory.ObjFactory import object_get_byval [as 別名]
class Test_ObjFrameworkGetByVal(unittest.TestCase):   
    # test we can find an return an object given the type and the value
    
    def setUp(self):
        self.of = ObjFactory(True)
        self.database = Database('foobar')
        
        datamembers = dict(period='830',
                           student='Booker',
                           dow='MO',
                           teacher='Amelia',
                           saveversion=0,
                           session='AM.AC.SC')

        self.foobar= self.of.new(schoolschedgeneric,
                                 'DBLesson',
                                 objid='dblesson0',
                                 constructor='datamembers',
                                 database=self.database,
                                 of=self.of,
                                 modname=__name__,
                                 dm=datamembers)
        
        datamembers = dict(period='910',
                           student='Clayton',
                           dow='TU',
                           teacher='Stan',
                           saveversion=0,
                           session='ST.AC.SC')

        self.foobar= self.of.new(schoolschedgeneric,
                                 'DBLesson',
                                 objid='dblesson1',
                                 constructor='datamembers',
                                 database=self.database,
                                 of=self.of,
                                 modname=__name__,
                                 dm=datamembers)
        
    def test_(self):

        self.assertEquals(self.of.object_get_byval("period","830").name,"830")        
        self.assertEquals(self.of.object_get_byval("period","910").name,"910")
        self.assertEquals(self.of.object_get_byval("period","foobar"),None)
開發者ID:burtnolej,項目名稱:hungrycrayon,代碼行數:46,代碼來源:test_misc_utils_objectfactory.py


注:本文中的misc_utils_objectfactory.ObjFactory.object_get_byval方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。