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

Method test_ByteString

Lib/test/test_collections.py:1938–1966  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1936 nativeseq, seqseq, (letter, start, stop))
1937
1938 def test_ByteString(self):
1939 previous_sys_modules = sys.modules.copy()
1940 self.addCleanup(sys.modules.update, previous_sys_modules)
1941
1942 for module in "collections", "_collections_abc", "collections.abc":
1943 sys.modules.pop(module, None)
1944
1945 with self.assertWarns(DeprecationWarning):
1946 from collections.abc import ByteString
1947 for sample in [bytes, bytearray]:
1948 with self.assertWarns(DeprecationWarning):
1949 self.assertIsInstance(sample(), ByteString)
1950 self.assertTrue(issubclass(sample, ByteString))
1951 for sample in [str, list, tuple]:
1952 with self.assertWarns(DeprecationWarning):
1953 self.assertNotIsInstance(sample(), ByteString)
1954 self.assertFalse(issubclass(sample, ByteString))
1955 with self.assertWarns(DeprecationWarning):
1956 self.assertNotIsInstance(memoryview(b""), ByteString)
1957 self.assertFalse(issubclass(memoryview, ByteString))
1958 with self.assertWarns(DeprecationWarning):
1959 self.validate_abstract_methods(ByteString, '__getitem__', '__len__')
1960
1961 with self.assertWarns(DeprecationWarning):
1962 class X(ByteString): pass
1963
1964 with self.assertWarns(DeprecationWarning):
1965 # No metaclass conflict
1966 class Z(ByteString, Awaitable): pass
1967
1968 def test_ByteString_attribute_access(self):
1969 collections_abc = import_fresh_module(

Callers

nothing calls this directly

Calls 10

sampleFunction · 0.85
addCleanupMethod · 0.80
assertWarnsMethod · 0.80
assertIsInstanceMethod · 0.80
assertTrueMethod · 0.80
assertNotIsInstanceMethod · 0.80
assertFalseMethod · 0.80
copyMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected