Tôi đang cố chạy doctest trên một hàm hoạt động với các giá trị rỗng. Nhưng doctest dường như không thích null ...Cách làm việc với null trong docutils
def do_something_with_hex(c):
"""
>>> do_something_with_hex('\x00')
'\x00'
"""
return repr(c)
import doctest
doctest.testmod()
tôi nhìn thấy các lỗi
Failed example:
do_something_with_hex(' ')
Exception raised:
Traceback (most recent call last):
File "C:\Python27\lib\doctest.py", line 1254, in __run
compileflags, 1) in test.globs
TypeError: compile() expected string without null bytes
**********************************************************************
Tôi có thể làm gì để cho phép null trong trường hợp thử nghiệm như thế này?
cảm ơn. làm việc một điều trị! –