当前位置: 首页>>代码示例>>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;未经允许,请勿转载。