簡體   English   中英

到底是什么被測試為“不正確:”?如何測試?

[英]What exactly is being tested as “not True:” and how?

我從閱讀作業中復制了一段代碼,並使用PyCharm跟蹤了示例代碼。 但是我對def to_string“ if not True”中的Boolean的用途感到困惑。 請把它弄一點,什么被測試為“不正確”,以及如何?

我有一些猜測,但最終還是想起了圈子。

# instance helpers -------------------------------------
def to_string(self, optional_title = "-------"):
    if not True:    # placeholder for real test
    ret_str = ( (optional_title
                 + "\n  name: {}"
                 + "\n    id: {}"
                 + "\n  temp: {}(F).").
                format(self.name, self.id, self.temperature) )
    return ret_str

正如評論中測試旁邊所說的那樣,它是真實測試的占位符。 not True則總會得出False因此if陳述永遠不會用占位符執行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM