本文整理汇总了Python中pymeta.runtime.OMetaBase.rule_letterOrDigit方法的典型用法代码示例。如果您正苦于以下问题:Python OMetaBase.rule_letterOrDigit方法的具体用法?Python OMetaBase.rule_letterOrDigit怎么用?Python OMetaBase.rule_letterOrDigit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymeta.runtime.OMetaBase
的用法示例。
在下文中一共展示了OMetaBase.rule_letterOrDigit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_letterOrDigit
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_letterOrDigit [as 别名]
def test_letterOrDigit(self):
"""
L{OMetaBase.rule_letterOrDigit} matches alphanumerics.
"""
o = OMetaBase("[email protected]")
v, e = o.rule_letterOrDigit()
self.assertEqual((v, e), ("a", [0, None]))
v, e = o.rule_letterOrDigit()
self.assertEqual((v, e), ("1", [1, None]))
e = self.assertRaises(ParseError, o.rule_letterOrDigit)
self.assertEqual(e, ParseError(2, expected("letter or digit")))
示例2: test_letterOrDigit
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_letterOrDigit [as 别名]
def test_letterOrDigit(self):
"""
L{OMetaBase.rule_letterOrDigit} matches alphanumerics.
"""
o = OMetaBase("[email protected]")
v, e = o.rule_letterOrDigit()
self.assertEqual((v, e), ("a", [0, None]))
v, e = o.rule_letterOrDigit()
self.assertEqual((v, e), ("1", [1, None]))
try:
o.rule_letterOrDigit()
except _MaybeParseError, e:
self.assertEqual(e, _MaybeParseError(2, expected("letter or digit")))
示例3: _MaybeParseError
# 需要导入模块: from pymeta.runtime import OMetaBase [as 别名]
# 或者: from pymeta.runtime.OMetaBase import rule_letterOrDigit [as 别名]
self.assertEqual((v, e), ("a", [0, None]))
v, e = o.rule_letterOrDigit()
self.assertEqual((v, e), ("1", [1, None]))
try:
o.rule_letterOrDigit()
except _MaybeParseError, e:
self.assertEqual(e, _MaybeParseError(2, expected("letter or digit")))
else:
self.fail('_MaybeParseError not raised')
# data = u"[email protected]£©™☺☹℅☐☑☒✓❍❖★☆€¥¢!¡?¿–_—·•%‰‱˚˛"
data = u"fooåßæø1234¹²³⁴₀₁₂₃"
o = OMetaBase(data)
for i, c in enumerate(data):
v, e = o.rule_letterOrDigit()
self.assertEqual((c, i), (v, e[0]))
def test_digit(self):
"""
L{OMetaBase.rule_digit} matches digits.
"""
o = OMetaBase("1a")
v, e = o.rule_digit()
self.assertEqual((v, e), ("1", [0, None]))
try:
o.rule_digit()
except _MaybeParseError, e:
self.assertEqual(e, _MaybeParseError(1, expected("digit")))
else:
self.fail('_MaybeParseError not raised')