![](/img/trans.png)
[英]pytest throws exception while using ClickArguments SystemExit: 0
[英]CLIPS (clear) command fails / throws exception in pyclips
我有一個pyclips / clips程序,為此我使用pytest編寫了一些單元測試。 每個測試用例都涉及一個初始clips.Clear()
然后通過clips.Load(rule_file.clp)
執行實際的剪輯COOL代碼。 單獨運行每個測試可以正常工作。
但是,當告訴pytest運行所有測試時, ClipsError: S03: environment could not be cleared
一些失敗。 實際上,這取決於.py文件中測試的順序。 似乎有測試用例,導致后續的測試用例引發異常。
也許某些剪輯代碼仍在“使用中”,所以清除失敗? 我在這里讀到(clear)
清除CLIPS。 從CLIPS環境中刪除所有構造和所有關聯的數據結構(例如事實和實例)。 可以隨時安全地執行清除操作,但是,某些構造在使用中時不允許其自身刪除。
可能是這種情況嗎? 是什么導致(clear)
命令失敗?
編輯:
我能夠縮小問題的范圍。 它在以下情況下發生:
test_case_A在test_case_B之前。 在test_case_A中,有一個test
例如
(test (eq (type ?f_bio_puts) clips_FUNCTION))
但f_bio_puts
已設置為
(slot f_bio_puts (default [nil]))
因此,測試最初已設置為[nil]
的slot變量的類型似乎會導致(clear)
命令失敗。 有任何想法嗎?
編輯2
我想我知道導致問題的原因。 這是test
線。 我修改了代碼,使其在剪輯對話框Windows中運行。 並且通過(batch ...)
加載時出現此錯誤
[INSFUN2] No such instance nil in function type.
[DRIVE1] This error occurred in the join network
Problem resided in associated join
Of pattern #1 in rule part_1
我猜這被掩蓋是pyclips的錯誤。
在CLIPS源代碼Construct.c文件中更改EnvClear函數,添加以下代碼行以重置錯誤標志:
globle void EnvClear(
void *theEnv)
{
struct callFunctionItem *theFunction;
/*==============================*/
/* Clear error flags if issued */
/* from an embedded controller. */
/*==============================*/
if ((EvaluationData(theEnv)->CurrentEvaluationDepth == 0) &&
(! CommandLineData(theEnv)->EvaluatingTopLevelCommand) &&
(EvaluationData(theEnv)->CurrentExpression == NULL))
{
SetEvaluationError(theEnv,FALSE);
SetHaltExecution(theEnv,FALSE);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.