Fix: Do not touch PAPI history on bad DICT__nodes
[csit.git] / resources / libraries / python / PapiHistory.py
index cacfbd6..32429c4 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -120,4 +120,9 @@ class PapiHistory:
                 PapiHistory.show_papi_history(node)
 
 
-PapiHistory.reset_papi_history_on_all_duts(DICT__nodes)
+# This module can be imported outside usual Robot test context,
+# e.g. in pylint or by tools generating docs from docstrings.
+# For the tools to work, we need to avoid processing
+# when DICT__nodes value is not usable.
+if DICT__nodes:
+    PapiHistory.reset_papi_history_on_all_duts(DICT__nodes)