]> granicus.if.org Git - python/commitdiff
With skipUnless there is no need to add test classes conditionally.
authorEzio Melotti <ezio.melotti@gmail.com>
Tue, 27 Jul 2010 22:24:13 +0000 (22:24 +0000)
committerEzio Melotti <ezio.melotti@gmail.com>
Tue, 27 Jul 2010 22:24:13 +0000 (22:24 +0000)
Lib/test/test_asyncore.py

index fe820de8f23cf43c3c12ea74fa28323755624a54..5a1b83ce627903be71630b35e4358b69b5a1b098 100644 (file)
@@ -693,18 +693,15 @@ class BaseTestAPI(unittest.TestCase):
 class TestAPI_UseSelect(BaseTestAPI):
     use_poll = False
 
+@unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required')
 class TestAPI_UsePoll(BaseTestAPI):
     use_poll = True
 
 
 def test_main():
     tests = [HelperFunctionTests, DispatcherTests, DispatcherWithSendTests,
-             DispatcherWithSendTests_UsePoll, TestAPI_UseSelect]
-    if hasattr(asyncore, 'file_wrapper'):
-        tests.append(FileWrapperTest)
-    if hasattr(select, 'poll'):
-        tests.append(TestAPI_UsePoll)
-
+             DispatcherWithSendTests_UsePoll, TestAPI_UseSelect,
+             TestAPI_UsePoll, FileWrapperTest]
     run_unittest(*tests)
 
 if __name__ == "__main__":