[V1] framework/tester:optimize handing of import error

Message ID 20220917130418.1690-1-zhiminx.huang@intel.com (mailing list archive)
State Accepted
Headers
Series [V1] framework/tester:optimize handing of import error |

Checks

Context Check Description
ci/Intel-dts-format-test success Testing OK
ci/Intel-dts-pylama-test success Testing OK
ci/Intel-dts-suite-test success Testing OK

Commit Message

Huang, ZhiminX Sept. 17, 2022, 1:04 p.m. UTC
  the scapy import module failed, it may not be ImportError.
except to import class failed, the module may also fail to import.
if the from module name does not exist, it's will report ModuleNotFoundError.
so add ModuleNotFoundError error in judgement.

Signed-off-by: Zhimin Huang <zhiminx.huang@intel.com>
---
 framework/tester.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Tu, Lijuan Oct. 10, 2022, 3:12 a.m. UTC | #1
On Sat, 17 Sep 2022 21:04:18 +0800, Zhimin Huang <zhiminx.huang@intel.com> wrote:
> the scapy import module failed, it may not be ImportError.
> except to import class failed, the module may also fail to import.
> if the from module name does not exist, it's will report ModuleNotFoundError.
> so add ModuleNotFoundError error in judgement.
> 
> Signed-off-by: Zhimin Huang <zhiminx.huang@intel.com>


Applied, thanks
  

Patch

diff --git a/framework/tester.py b/framework/tester.py
index 7414efea..9a228f14 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -87,7 +87,7 @@  class Tester(Crb):
 
         # import scapy moudle to scapy APP
         out = session.session.send_expect(get_scapy_module_impcmd(), ">>> ")
-        if "ImportError" in out:
+        if "ImportError" in out or "ModuleNotFoundError" in out:
             session.logger.warning(f"entering import error: {out}")
 
         return session