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


Python Foo.parse方法代碼示例

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


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

示例1: test_parse_error

# 需要導入模塊: from bindertest.tabledefs import Foo [as 別名]
# 或者: from bindertest.tabledefs.Foo import parse [as 別名]
 def test_parse_error(self):
     # parse() gives parse error for bad strings
     try:
         Foo.parse(i1="2.3", s2=1.1)
     except ValueError, e:
         self.assert_(
                 str(e) in [
                         "invalid literal for int(): 2.3",
                         "invalid literal for int() with base 10: '2.3'",
                     ]
             )
開發者ID:divtxt,項目名稱:binder,代碼行數:13,代碼來源:test_table.py

示例2: test_new_parse_all

# 需要導入模塊: from bindertest.tabledefs import Foo [as 別名]
# 或者: from bindertest.tabledefs.Foo import parse [as 別名]
 def test_new_parse_all(self):
     expected = {
         "foo_id": 42,
         "i1": 101,
         "s1": "alpha",
         "d1": date(2006,6,6),
     }
     actual = Foo.new(foo_id=42, i1=101, s1="alpha", d1=date(2006,6,6))
     self.assertEquals(expected, actual)
     actual = Foo.parse(foo_id="42", i1="101", s1="alpha", d1="2006-06-06")
     self.assertEquals(expected, actual)
     # parse some fields str
     actual = Foo.parse(foo_id="42", i1=101, s1="alpha", d1=date(2006,6,6))
     self.assertEquals(expected, actual)
開發者ID:divtxt,項目名稱:binder,代碼行數:16,代碼來源:test_table.py

示例3: test_parse_auto_id

# 需要導入模塊: from bindertest.tabledefs import Foo [as 別名]
# 或者: from bindertest.tabledefs.Foo import parse [as 別名]
 def test_parse_auto_id(self):
     expected = {
         "foo_id": None,
         "i1": 0,
         "s1": "",
         "d1": None,
     }
     actual = Foo.parse(foo_id=None)
     self.assertEquals(expected, actual)
開發者ID:divtxt,項目名稱:binder,代碼行數:11,代碼來源:test_table.py

示例4: test_new_parse_some_fields

# 需要導入模塊: from bindertest.tabledefs import Foo [as 別名]
# 或者: from bindertest.tabledefs.Foo import parse [as 別名]
 def test_new_parse_some_fields(self):
     expected = {
         "foo_id": 42,
         "i1": 0,
         "s1": "alpha",
         "d1": None,
     }
     actual = Foo.new(foo_id=42, s1="alpha")
     self.assertEquals(expected, actual)
     actual = Foo.parse(foo_id="42", s1="alpha")
     self.assertEquals(expected, actual)
開發者ID:divtxt,項目名稱:binder,代碼行數:13,代碼來源:test_table.py

示例5: test_new_parse_unkown_cols

# 需要導入模塊: from bindertest.tabledefs import Foo [as 別名]
# 或者: from bindertest.tabledefs.Foo import parse [as 別名]
 def test_new_parse_unkown_cols(self):
     # DONT copy unknown columns
     expected = {
         "foo_id": None,
         "i1": 16,
         "s1": "",
         "d1": None,
     }
     actual = Foo.new(i1=16, s2="beta")
     self.assertEquals(expected, actual)
     actual = Foo.parse(i1="16", s2="beta")
     self.assertEquals(expected, actual)
開發者ID:divtxt,項目名稱:binder,代碼行數:14,代碼來源:test_table.py

示例6: test_new_parse_clone

# 需要導入模塊: from bindertest.tabledefs import Foo [as 別名]
# 或者: from bindertest.tabledefs.Foo import parse [as 別名]
 def test_new_parse_clone(self):
     # new() and parse() should return a new dictionary
     expected = {
         "foo_id": 42,
         "i1": 0,
         "s1": "alpha",
         "d1": None,
     }
     actual = Foo.new(**expected)
     self.assertEquals(expected, actual)
     self.assertFalse(actual is expected)
     actual = Foo.parse(**expected)
     self.assertEquals(expected, actual)
     self.assertFalse(actual is expected)
開發者ID:divtxt,項目名稱:binder,代碼行數:16,代碼來源:test_table.py

示例7: test_parse_empty_string

# 需要導入模塊: from bindertest.tabledefs import Foo [as 別名]
# 或者: from bindertest.tabledefs.Foo import parse [as 別名]
 def test_parse_empty_string(self):
     # parse() replaces empty strings with default value
     expected = {
         "foo_id": None,
         "i1": 0,
         "s1": "",
         "d1": None,
     }
     actual = Foo.parse(foo_id="", i1="", s1="", d1="")
     self.assertEquals(expected, actual)
     expected = {
         "bi": None,
         "bs": "",
         "bd": None,
         "bdt1": None,
         "bb": False,
     }
     actual = Bar.parse(bi="", bs="", bd="", bdt1="", bb="")
     self.assertEquals(expected, actual)
開發者ID:divtxt,項目名稱:binder,代碼行數:21,代碼來源:test_table.py

示例8: test_new_parse_defaults

# 需要導入模塊: from bindertest.tabledefs import Foo [as 別名]
# 或者: from bindertest.tabledefs.Foo import parse [as 別名]
 def test_new_parse_defaults(self):
     expected = {
         "foo_id": None,
         "i1": 0,
         "s1": "",
         "d1": None,
     }
     actual = Foo.new()
     self.assertEquals(expected, actual)
     actual = Foo.parse()
     self.assertEquals(expected, actual)
     expected = {
         "bi": None,
         "bs": "",
         "bd": None,
         "bdt1": None,
         "bb": False,
     }
     actual = Bar.new()
     self.assertEquals(expected, actual)
     actual = Bar.parse()
     self.assertEquals(expected, actual)
開發者ID:divtxt,項目名稱:binder,代碼行數:24,代碼來源:test_table.py

示例9: test_parse_bad_values

# 需要導入模塊: from bindertest.tabledefs import Foo [as 別名]
# 或者: from bindertest.tabledefs.Foo import parse [as 別名]
 def test_parse_bad_values(self):
     # parse() does not allow non-string bad values
     try:
         Foo.parse(i1=2.3, s2=1.1)
     except TypeError, e:
         self.assertEquals("IntCol 'i1': int expected, got float", str(e))
開發者ID:divtxt,項目名稱:binder,代碼行數:8,代碼來源:test_table.py


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