From 9e454235b31cd35e3ff74fd031238bd630a7d74f Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 8 Dec 2014 21:15:39 +0300 Subject: [PATCH] Skip testing cpu_load_percent if psutil module is not available --- tests/test_segments.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_segments.py b/tests/test_segments.py index a814ac32..606a21e3 100644 --- a/tests/test_segments.py +++ b/tests/test_segments.py @@ -721,6 +721,10 @@ class TestSys(TestCommon): ]) def test_cpu_load_percent(self): + try: + __import__('psutil') + except ImportError as e: + raise SkipTest('Failed to import psutil: {0}'.format(e)) pl = Pl() with replace_module_module(self.module, 'psutil', cpu_percent=lambda **kwargs: 52.3): self.assertEqual(common.cpu_load_percent(pl=pl), [{