MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_ios_ver

Method test_ios_ver

Lib/test/test_platform.py:443–491  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

441 support.wait_process(pid, exitcode=0)
442
443 def test_ios_ver(self):
444 result = platform.ios_ver()
445
446 # ios_ver is only fully available on iOS where ctypes is available.
447 if sys.platform == "ios" and _ctypes:
448 system, release, model, is_simulator = result
449 # Result is a namedtuple
450 self.assertEqual(result.system, system)
451 self.assertEqual(result.release, release)
452 self.assertEqual(result.model, model)
453 self.assertEqual(result.is_simulator, is_simulator)
454
455 # We can't assert specific values without reproducing the logic of
456 # ios_ver(), so we check that the values are broadly what we expect.
457
458 # System is either iOS or iPadOS, depending on the test device
459 self.assertIn(system, {"iOS", "iPadOS"})
460
461 # Release is a numeric version specifier with at least 2 parts
462 parts = release.split(".")
463 self.assertGreaterEqual(len(parts), 2)
464 self.assertTrue(all(part.isdigit() for part in parts))
465
466 # If this is a simulator, we get a high level device descriptor
467 # with no identifying model number. If this is a physical device,
468 # we get a model descriptor like "iPhone13,1"
469 if is_simulator:
470 self.assertIn(model, {"iPhone", "iPad"})
471 else:
472 self.assertTrue(
473 (model.startswith("iPhone") or model.startswith("iPad"))
474 and "," in model
475 )
476
477 self.assertEqual(type(is_simulator), bool)
478 else:
479 # On non-iOS platforms, calling ios_ver doesn't fail; you get
480 # default values
481 self.assertEqual(result.system, "")
482 self.assertEqual(result.release, "")
483 self.assertEqual(result.model, "")
484 self.assertFalse(result.is_simulator)
485
486 # Check the fallback values can be overridden by arguments
487 override = platform.ios_ver("Foo", "Bar", "Whiz", True)
488 self.assertEqual(override.system, "Foo")
489 self.assertEqual(override.release, "Bar")
490 self.assertEqual(override.model, "Whiz")
491 self.assertTrue(override.is_simulator)
492
493 @unittest.skipIf(support.is_emscripten, "Does not apply to Emscripten")
494 def test_libc_ver(self):

Callers

nothing calls this directly

Calls 10

lenFunction · 0.85
allFunction · 0.85
assertInMethod · 0.80
assertGreaterEqualMethod · 0.80
assertTrueMethod · 0.80
assertFalseMethod · 0.80
assertEqualMethod · 0.45
splitMethod · 0.45
isdigitMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected