def test_custom_coder(self): self.check_coder(CustomCoder(), 1, -10, 5) self.check_coder( coders.TupleCoder((CustomCoder(), coders.BytesCoder())), (1, 'a'), (-10, 'b'), (5, 'c'))
def test_bytes_coder(self): self.check_coder(coders.BytesCoder(), 'a', '\0', 'z' * 1000)
def test_standard_str_coder(self): real_coder = typecoders.registry.get_coder(bytes) expected_coder = coders.BytesCoder() self.assertEqual(real_coder.encode(b'abc'), expected_coder.encode(b'abc')) self.assertEqual(b'abc', real_coder.decode(real_coder.encode(b'abc')))
def get_window_coder(self): return coders.BytesCoder()
def test_iterable_coder(self): real_coder = typecoders.registry.get_coder(typehints.Iterable[bytes]) expected_coder = coders.IterableCoder(coders.BytesCoder()) values = [b'abc', b'xyz'] self.assertEqual(expected_coder, real_coder) self.assertEqual(real_coder.encode(values), expected_coder.encode(values))