diff options
author | Charles-Francois Natali <cf.natali@gmail.com> | 2013-05-20 12:40:46 (GMT) |
---|---|---|
committer | Charles-Francois Natali <cf.natali@gmail.com> | 2013-05-20 12:40:46 (GMT) |
commit | 44feda3cd0454cd00028e09f3151de67e8aad76f (patch) | |
tree | a96b037934976f43273b9c6347b2cf098e7bb813 /Lib/test/test_os.py | |
parent | 93c6770c7202ea8c123a1d04e76be1007584697e (diff) | |
download | cpython-44feda3cd0454cd00028e09f3151de67e8aad76f.zip cpython-44feda3cd0454cd00028e09f3151de67e8aad76f.tar.gz cpython-44feda3cd0454cd00028e09f3151de67e8aad76f.tar.bz2 |
Issue #17914: Add os.cpu_count(). Patch by Yogesh Chaudhari, based on an
initial patch by Trent Nelson.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r-- | Lib/test/test_os.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 3a38285..65d3c3b 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -2216,6 +2216,15 @@ class OSErrorTests(unittest.TestCase): else: self.fail("No exception thrown by {}".format(func)) +class CPUCountTests(unittest.TestCase): + def test_cpu_count(self): + cpus = os.cpu_count() + if cpus is not None: + self.assertIsInstance(cpus, int) + self.assertGreater(cpus, 0) + else: + self.skipTest("Could not determine the number of CPUs") + @support.reap_threads def test_main(): support.run_unittest( @@ -2246,6 +2255,7 @@ def test_main(): TermsizeTests, OSErrorTests, RemoveDirsTests, + CPUCountTests, ) if __name__ == "__main__": |