![](/img/trans.png)
[英]Pytest fails when using pyhamcrest raises
目前我有一個如下的測試用例: def test_foo(self): assert_that(self.target.do(), raises(FileNotFoundError)) 使用標准 python 單元測試框架通過,但是如果我更改為使用 pytest,它會失敗。 切 ...
[英]Pytest fails when using pyhamcrest raises
目前我有一個如下的測試用例: def test_foo(self): assert_that(self.target.do(), raises(FileNotFoundError)) 使用標准 python 單元測試框架通過,但是如果我更改為使用 pytest,它會失敗。 切 ...
[英]Python: Assert mock function was called with a string containing another string
這是我面臨的問題的簡化版本:假設我有一個 function 接受目錄路徑,然后刪除其所有內容,除了(可選)指定的“保留文件”,import os KEEP_FILE_CONSTANT = '.gitkeep' def clear_directory(directory: str, retain: ...
[英]hamcrest: how to input Boolean value
我不知道為什么當我有這個代碼時會看到錯誤。 all_is_valid 以黃色突出顯示,當我將鼠標懸停在上面時,我會看到以下錯誤消息。 如何避免不突出顯示? 預期類型 'Matcher[bool]'(匹配泛型類型 'Matcher[T]'),而是得到 'bool' ...
[英]This is my program when i return num_list it doesn't work but when i put print it work smoothly,
這是我的程序,當我返回 num_list 時它不起作用,但是當我打印它時,它運行順利,我的程序和另一個朋友的程序完全相同,但他的程序工作而我的程序沒有。 ...
[英]pyhamcrest - Compare two list
我剛開始學習python。 當前正在編寫單元測試來斷言預期列表中的元素是否存在於實際列表中 但我收到了類似的錯誤 我應該如何以及使用什么序列匹配器來斷言預期列表中的項目“a”是否存在於實際列表中? ...
[英]pyhamcrest contains matcher for list of dicts
為什么pyhamcrest對於2個或更多字典的列表失敗contains()匹配器,但對於1個字典的列表卻能正常工作? PyHamcrest包含 為字典列表編寫hamcrest(pyhamcrest)匹配器的最佳方法是什么? 在此單元測試示例中,第一次測試通過,第二次失敗。 ...
[英]Why doesn't PyHamcrest have a negative equality matcher?
回顧PyHamcrest的API ,我看到有一個equal_to匹配器 但沒有諸如not_equal_to這樣的並行否定方法 匹配否定相等的正確方法是什么? ...