annoying doctest problem
gordianknot1981 at gmail.com
gordianknot1981 at gmail.com
Sun Jan 11 23:20:35 EST 2015
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
kivy_class_ptn = re.compile(r"<\b[\w_.\@\+]+>:?")
def test_kivy_class(s):
"""
>>> s = "<MYBT at ToggleButton+Button>:"
>>> test_kivy_class(s)
"<MYBT at ToggleButton+Button>:"
>>> s = "<MYBT>"
>>> test_kivy_class(s)
"<MYBT>"
"""
ret = re.search(kivy_class_ptn, s)
if ret: return ret.group()
else: return ''
if __name__ == "__main__":
import doctest
doctest.testmod()
output:
**********************************************************************
File "F:/MyDocument/[Programing]/Python/PhotoshopAsGui/python3_branch/regexSnippet.py", line 19, in __main__.test_kivy_class
Failed example:
test_kivy_class(s)
Expected:
"<MYBT at ToggleButton+Button>:"
Got:
'<MYBT at ToggleButton+Button>:'
**********************************************************************
File "F:/MyDocument/[Programing]/Python/PhotoshopAsGui/python3_branch/regexSnippet.py", line 22, in __main__.test_kivy_class
Failed example:
test_kivy_class(s)
Expected:
"<MYBT>"
Got:
'<MYBT>'
**********************************************************************
1 items had failures:
2 of 8 in __main__.test_kivy_class
***Test Failed*** 2 failures.
It failed with an unknown reason that evaluate two expected equal value but got an unexpected result! I'm struggling with this problem for a long time. Did I did something wrong? And how do I to fix it?
any help is appreciated. :)
More information about the Python-list
mailing list