【问题标题】:python doctest truncates expected outputpython doctest 截断预期输出
【发布时间】:2014-07-30 22:47:27
【问题描述】:

我想运行这个 doctest 并检查输出:

>>> execfile("scss_converter_1.5.1_v1.py") #doctest: +NORMALIZE_WHITESPACE +DONT_ACCEPT_BLANKLINE
body {

    .boxholder {

        .box {

            .col {

                .something {

                    .something.else {

                    }

                }

                img {

                }

                a {

                    .my.span {

                    }

                }

                ul {

                    .list-item {

                    }

                }

                #some-button {

                }

            }

        }

        .another-box.crazy.very.insane {

        }

    }

}
"""

但是当我运行测试时,它说预期的输出是:

Expected:
    body {

有什么方法可以让它期望包含所有单词的完整字符串?换行通常意味着预期输出的结束,不是这样,所以很棘手。

干杯

【问题讨论】:

    标签: python doctest


    【解决方案1】:

    根据the docs,doctest 的预期输出以全空白行或以>>> 开头的行结束。如果空白行是输出的重要部分,您可以通过将所有空白行替换为 <BLANKLINE> 来转义它们。

    【讨论】:

      猜你喜欢
      • 2020-05-19
      • 2012-12-08
      • 1970-01-01
      • 2020-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多