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

Method test_attributes

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 13

lenFunction · 0.85
hasattrFunction · 0.85
assertIsInstanceMethod · 0.80
assertInMethod · 0.80
assertTrueMethod · 0.80
assertGreaterEqualMethod · 0.80
assertGreaterMethod · 0.80
assertFalseMethod · 0.80
powFunction · 0.50
assertEqualMethod · 0.45
assertLessMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected