MCPcopy Index your code
hub / github.com/python/cpython / test_attributes

Method test_attributes

Lib/test/test_sys.py:630–725  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

628 t.join()
629
630 def test_attributes(self):
631 self.assertIsInstance(sys.api_version, int)
632 self.assertIsInstance(sys.argv, list)
633 for arg in sys.argv:
634 self.assertIsInstance(arg, str)
635 self.assertIsInstance(sys.orig_argv, list)
636 for arg in sys.orig_argv:
637 self.assertIsInstance(arg, str)
638 self.assertIn(sys.byteorder, ("little", "big"))
639 self.assertIsInstance(sys.builtin_module_names, tuple)
640 self.assertIsInstance(sys.copyright, str)
641 self.assertIsInstance(sys.exec_prefix, str)
642 self.assertIsInstance(sys.base_exec_prefix, str)
643 self.assertIsInstance(sys.executable, str)
644 self.assertEqual(len(sys.float_info), 11)
645 self.assertEqual(sys.float_info.radix, 2)
646 self.assertEqual(len(sys.int_info), 4)
647 self.assertTrue(sys.int_info.bits_per_digit % 5 == 0)
648 self.assertTrue(sys.int_info.sizeof_digit >= 1)
649 self.assertGreaterEqual(sys.int_info.default_max_str_digits, 500)
650 self.assertGreaterEqual(sys.int_info.str_digits_check_threshold, 100)
651 self.assertGreater(sys.int_info.default_max_str_digits,
652 sys.int_info.str_digits_check_threshold)
653 self.assertEqual(type(sys.int_info.bits_per_digit), int)
654 self.assertEqual(type(sys.int_info.sizeof_digit), int)
655 self.assertIsInstance(sys.int_info.default_max_str_digits, int)
656 self.assertIsInstance(sys.int_info.str_digits_check_threshold, int)
657 self.assertIsInstance(sys.hexversion, int)
658
659 self.assertEqual(len(sys.hash_info), 9)
660 self.assertLess(sys.hash_info.modulus, 2**sys.hash_info.width)
661 # sys.hash_info.modulus should be a prime; we do a quick
662 # probable primality test (doesn't exclude the possibility of
663 # a Carmichael number)
664 for x in range(1, 100):
665 self.assertEqual(
666 pow(x, sys.hash_info.modulus-1, sys.hash_info.modulus),
667 1,
668 "sys.hash_info.modulus {} is a non-prime".format(
669 sys.hash_info.modulus)
670 )
671 self.assertIsInstance(sys.hash_info.inf, int)
672 self.assertIsInstance(sys.hash_info.nan, int)
673 self.assertIsInstance(sys.hash_info.imag, int)
674 algo = sysconfig.get_config_var("Py_HASH_ALGORITHM")
675 if sys.hash_info.algorithm in {"fnv", "siphash13", "siphash24"}:
676 self.assertIn(sys.hash_info.hash_bits, {32, 64})
677 self.assertIn(sys.hash_info.seed_bits, {32, 64, 128})
678
679 if algo == 1:
680 self.assertEqual(sys.hash_info.algorithm, "siphash24")
681 elif algo == 2:
682 self.assertEqual(sys.hash_info.algorithm, "fnv")
683 elif algo == 3:
684 self.assertEqual(sys.hash_info.algorithm, "siphash13")
685 else:
686 self.assertIn(sys.hash_info.algorithm, {"fnv", "siphash13", "siphash24"})
687 else:

Callers

nothing calls this directly

Calls 11

powFunction · 0.85
assertIsInstanceMethod · 0.80
assertInMethod · 0.80
assertTrueMethod · 0.80
assertGreaterEqualMethod · 0.80
assertGreaterMethod · 0.80
assertFalseMethod · 0.80
assertEqualMethod · 0.45
assertLessMethod · 0.45
formatMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected