简体   繁体   English

是否有一个python单元测试框架,在比较字符串时提供紧凑的错误输出

[英]Is there a python unit test framework that gives compact error output when comparing strings

Using the Java JUnit framework and comparing the strings "abcde" and "abde" you would get the error output 'expected:<...b[c]d...> but was: <...b[]d...>' 使用Java JUnit框架并比较字符串“abcde”和“abde”,您将得到错误输出'expected:<... b [c] d ...>但是:<... b [] d。 ..>”

Using python unittest I get "abcde" != "abde" which is not all as useful if you are dealing with long strings. 使用python unittest我得到“abcde”!=“abde”,如果你处理长字符串,这并不是很有用。

So my question is: Is there a python unit test framework that gives the same compact output as JUnit for Java? 所以我的问题是:是否有一个python单元测试框架,它提供与JUnit for Java相同的紧凑输出?

The unittest2 package is a backport (to Python >= 2.4) of features that are native to the PyUnit (unittest) framework in Python 2.7. unittest2包是Python3.7中PyUnit(unittest)框架的原生特性的后端(Python> = 2.4)。

It includes enhanced string comparison features. 它包括增强的字符串比较功能。 替代文字 http://www.voidspace.org.uk/python/articles/unittest2.shtml#unicode-string-comparison http://www.voidspace.org.uk/python/articles/unittest2.shtml#unicode-string-comparison

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM