mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
Issue #17914: Add os.cpu_count(). Patch by Yogesh Chaudhari, based on an
initial patch by Trent Nelson.
This commit is contained in:
parent
93c6770c72
commit
44feda3cd0
6 changed files with 95 additions and 27 deletions
|
|
@ -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__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue