From 05928f912a7789a3784c1513a9c975552466daa0 Mon Sep 17 00:00:00 2001 From: Sergey Shepelev Date: Tue, 9 Jul 2013 20:07:11 +0400 Subject: [PATCH] tests: skip check_idle_cpu_usage on Windows; Thanks to Paul Oppenheim TODO: use psutil package which ought to work on Windows --- tests/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/__init__.py b/tests/__init__.py index 02002fd..b52d6bc 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,7 +1,10 @@ # package is named tests, not test, so it won't be confused with test in stdlib import errno import os -import resource +try: + import resource +except ImportError: + resource = None import signal import unittest import warnings @@ -201,6 +204,11 @@ class LimitedTestCase(unittest.TestCase): def check_idle_cpu_usage(duration, allowed_part): + if resource is None: + # TODO: use https://code.google.com/p/psutil/ + from nose.plugins.skip import SkipTest + raise SkipTest('CPU usage testing not supported (`import resource` failed)') + r1 = resource.getrusage(resource.RUSAGE_SELF) eventlet.sleep(duration) r2 = resource.getrusage(resource.RUSAGE_SELF)