我为我最新的Python项目设置了一个CI管道(Gitlab CI,如果这很重要),并为我仍想实现的内容添加了几个测试用例。在每个测试用例中,我都会提出NotImplementedError
,因为它尚未实现。
import unittest
class GenericTest(unittest.TestCase):
def test_stuff(self):
"""I'll fill this in when I come around to it."""
raise NotImplementedError
通常,我希望这些测试失败,因为还没有正常工作。但是,当我推送到我的存储库并且测试在CI系统上运行时,我想跳过这些测试。我已经知道他们会“失败”,他们会掩盖实际失败的测试。
是否有办法抑制这些异常或特定类型的异常(如IKnowThisWillFailError
),以便受影响的测试不会被视为“失败”?
答案 0 :(得分:2)
怎么样
import unittest
class GenercTest(unittest.TestCase):
def test_stuff(self):
"""I'll fill this in when I come around to it."""
raise unittest.SkipTest("IKnowThisWillFail")
您的CI系统可能可以区分跳过和失败的测试
答案 1 :(得分:0)
<asp:TextBox ID="txtDrg" onkeypress="SearchText('DRG',this,event);" runat="server" ></asp:TextBox>
function SearchText(searchType, searchKey, event) {
if (searchType != '' && searchKey != '') {
var x = event.which || event.keyCode;
var searchKeyWord = '';
if (searchType == 'DRG') {
if (x == 8 || x == 46) {
if (searchKey.value.length > 0) {
searchKeyWord = searchKey.value.toString().slice(0, -1);
}
}
else {
if (x == 110 || x == 190)
searchKeyWord = '.';
else
searchKeyWord = String.fromCharCode(x);
if (searchKey.value != '' || searchKey.value != undefined)
searchKeyWord = searchKey.value + searchKeyWord;
}
if (valiadte)
GetAutoData(searchType, searchKeyWord);
}
}
}
function GetAutoData() {
//code
}