我正在扩展python 2.7 unittest框架来进行一些功能测试.我想做的一件事就是阻止所有测试在测试内部和setUpClass()方法内部运行.有时如果测试失败,程序就会破坏,不再有任何用处继续测试,所以我想阻止测试运行.
我注意到TestResult有一个shouldStop属性和一个stop()方法,但我不确定如何访问测试内部.
有没有人有任何想法?有没有更好的办法?
python testing automated-tests functional-testing python-unittest
我有一个包含复杂类型的WSDL,如下所示:
<xsd:complexType name="string_array">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
Run Code Online (Sandbox Code Playgroud)
我决定对soap客户端使用zeep,并希望将该类型用作WSDL中引用的其他方法之一的参数.我似乎无法弄清楚如何使用这种类型.当我通过看文件关于如何使用WSDL中引用的某些数据结构,它说,使用client.get_type()方法,所以我做了以下内容:
wsdl = "https://wsdl.location.com/?wsdl"
client = Client(wsdl=wsdl)
string_array = client.get_type('tns:string_array')
string_array('some value')
client.service.method(string_array)
Run Code Online (Sandbox Code Playgroud)
这给出了一个错误TypeError: argument of type 'string_array' is not iterable.我也试过很多变化,并尝试使用这样的字典:
client.service.method(param_name=['some value'])
Run Code Online (Sandbox Code Playgroud)
这给出了错误
ValueError: Error while create XML for complexType '{https://wsdl.location.com/?wsdl}string_array': Expected instance of type <class 'zeep.objects.string_array'>, received <class 'str'> instead.`
Run Code Online (Sandbox Code Playgroud)
如果有人知道如何使用带有zeep的WSDL中的上述类型,我将不胜感激.谢谢.
我想使用python日志记录模块记录unittest的所有输出,以便我可以将它合并到我试图编写的测试框架中.这样做的目的是使用2组输出运行测试,一组具有简单输出,告诉测试用例步骤和更多调试级别输出,以便在出现问题时尽可能多地提供信息.输出将被放入两个文件中,一个可以通过电子邮件发送给人们,另一个可以保存.我注意到TextTestRunner可以使用流,这可以用于日志记录模块吗?我打算在python 2.7中使用一些新功能.