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

Method test_sys_flags_indexable_attributes

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

Source from the content-addressed store, hash-verified

859 self.assertTrue(sys._is_interned(s))
860
861 def test_sys_flags_indexable_attributes(self):
862 self.assertTrue(sys.flags)
863 # We've stopped assigning sequence indices to new sys.flags attributes:
864 # https://github.com/python/cpython/issues/122575#issuecomment-2416497086
865 indexable_attrs = ("debug",
866 "inspect", "interactive", "optimize",
867 "dont_write_bytecode", "no_user_site", "no_site",
868 "ignore_environment", "verbose", "bytes_warning", "quiet",
869 "hash_randomization", "isolated", "dev_mode", "utf8_mode",
870 "warn_default_encoding", "safe_path", "int_max_str_digits")
871 for attr_idx, attr in enumerate(indexable_attrs):
872 self.assertHasAttr(sys.flags, attr)
873 attr_type = bool if attr in ("dev_mode", "safe_path") else int
874 self.assertEqual(type(getattr(sys.flags, attr)), attr_type, attr)
875 attr_value = getattr(sys.flags, attr)
876 self.assertEqual(sys.flags[attr_idx], attr_value,
877 msg=f"sys.flags .{attr} vs [{attr_idx}]")
878 self.assertTrue(repr(sys.flags))
879 self.assertEqual(len(sys.flags), 18, msg="Do not increase, see GH-122575")
880
881 self.assertIn(sys.flags.utf8_mode, {0, 1, 2})
882
883 def test_sys_flags_name_only_attributes(self):
884 # non-tuple sequence fields (name only sys.flags attributes)

Callers

nothing calls this directly

Calls 5

enumerateFunction · 0.85
assertTrueMethod · 0.80
assertHasAttrMethod · 0.80
assertInMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected