Can python doctest ignore some output lines?

后端 未结 6 1608
灰色年华
灰色年华 2020-12-09 15:16

I\'d like to write a doctest like this:

\"\"\"
>>> print a.string()
          foo : a
          bar : b
         date : 

        
6条回答
  •  盖世英雄少女心
    2020-12-09 15:33

    You can write tuples before and after your function (hack inspired by answer of Mark Horvath):

    def foo():
        """
        >>> ();foo();() # doctest: +ELLIPSIS
        (...)
        """
        print "Hello world"
        return "Hello world"
    

提交回复
热议问题