Can I have an ellipsis at the beginning of the line in a Python doctest?

前端 未结 4 2030
我寻月下人不归
我寻月下人不归 2021-01-17 09:37

Python doctests are cool. Let me start with a simple example:

def foo():
  \"\"\"
  >>> foo()
  hello world
  \"\"\"
  print \"hello world\"
         


        
4条回答
  •  温柔的废话
    2021-01-17 10:16

    I ended up with this workaround.

    def foo():
        """
        >>> foo()  # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
        
        ... world
        """
        print("hello world")
    

    It at least works without non-whitespace characters or other workarounds.

提交回复
热议问题