def test_string_length(self): """ Test that string length is respected. """ self.n = bencode.decode_str("1:abc") self.assertEqual(self.n, "a")
def test_str(self): bencode = [b'13:parrot sketch', b'6:github'] real = [b'parrot sketch', b'github'] for (bencode, real) in list(zip(bencode, real)): assert decode_str(bencode, 0)[0] == real
def test_string(self): """ Test that a string is decoded correctly. """ self.n = bencode.decode_str("4:test") self.assertEqual(self.n, "test")
def test_long_string(self): """ Test that a long string is decoded correctly. """ self.n = bencode.decode_str("15:averylongstring") self.assertEqual(self.n, "averylongstring")
def test_character(self): """ Test that a single character is decoded correctly """ self.n = bencode.decode_str("1:a") self.assertEqual(self.n, "a")
def test_exception_on_wrong_datatype(self): with self.assertRaises(b.BencodeError) as context: b.decode_str('i23e')
def test_str_len(self): self.assertEqual('hello', b.decode_str('5:helloworld'))
def test_long_string(self): self.assertEqual('dweirieakddewqw', b.decode_str( '15:dweirieakddewqw'))
def test_single_char(self): self.assertEqual('a', b.decode_str( '1:a'))