summaryrefslogtreecommitdiff
path: root/psutil/tests/test_system.py
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2018-07-16 00:10:03 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2018-07-16 00:10:03 +0200
commitcf9d1cd9045e4d73ecd2d7308183d254081bc9b3 (patch)
tree1380f6d942c3f7312df10a0e9218d61c12f00030 /psutil/tests/test_system.py
parentf440b6e3c6e9bbcd3e57f9c0d2f78aef36a249b1 (diff)
downloadpsutil-cf9d1cd9045e4d73ecd2d7308183d254081bc9b3.tar.gz
fix #1279: catch and skip ENODEV in net_if_stat()
Diffstat (limited to 'psutil/tests/test_system.py')
-rwxr-xr-xpsutil/tests/test_system.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py
index 694a7a3b..18cbb5d8 100755
--- a/psutil/tests/test_system.py
+++ b/psutil/tests/test_system.py
@@ -671,6 +671,16 @@ class TestSystemAPIs(unittest.TestCase):
self.assertGreaterEqual(speed, 0)
self.assertGreaterEqual(mtu, 0)
+ @unittest.skipIf(not (LINUX or BSD or MACOS),
+ "LINUX or BSD or MACOS specific")
+ def test_net_if_stats_enodev(self):
+ # See: https://github.com/giampaolo/psutil/issues/1279
+ with mock.patch('psutil._psutil_posix.net_if_mtu',
+ side_effect=OSError(errno.ENODEV, "")) as m:
+ ret = psutil.net_if_stats()
+ self.assertEqual(ret, {})
+ assert m.called
+
@unittest.skipIf(LINUX and not os.path.exists('/proc/diskstats'),
'/proc/diskstats not available on this linux version')
@unittest.skipIf(APPVEYOR and psutil.disk_io_counters() is None,