I am trying to create a doctest test case for the following:

def quote_value(s):
    """Quote the value for a key-value pair in Received-SPF header field
    if needed.  No quoting needed for a dot-atom value.

    >>> quote_value(r'abc\def')
    '"abc\\\\\\\\def"'
    >>> quote_value('abc..def')
    '"abc..def"'
    >>> quote_value('')
    '""'
    >>> quote_value('-all\x00')
    '"-all\\\\\\\\x00"'
    ...

However, doctest does *not* like the null byte in the example (yes, this
happens with real life input):
**********************************************************************
File "/home/stuart/pyspf/spf.py", line 1453, in spf.quote_value
Failed example:
    quote_value('-all')
Exception raised:
    Traceback (most recent call last):
      File "/var/tmp/python2.4-2.4.4c1-root/usr/lib/python2.4/doctest.py",
        line 1248, in __run
        compileflags, 1) in test.globs
    TypeError: compile() expected string without null bytes
**********************************************************************

How can I construct a test cast for this?

-- 
              Stuart D. Gathman <[EMAIL PROTECTED]>
Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to