Пример #1
0
    def test_mixed_dict(self):
        """ Test that a dict with a list value is encoded correctly. """

        self.n = bencode.encode_dict({'key': ['a', 'b']})
        self.assertEquals(self.n, "d3:keyl1:a1:bee")
Пример #2
0
    def test_nested_dict(self):
        """ Test that a nested dict is encoded correctly. """

        self.n = bencode.encode_dict({"key": {"key": "value"}})
        self.assertEquals(self.n, "d3:keyd3:key5:valueee")
Пример #3
0
    def test_simple_dict(self):
        """ Test that a one key dict is encoded correctly. """

        self.n = bencode.encode_dict({"key": "value"})
        self.assertEquals(self.n, "d3:key5:valuee")
Пример #4
0
    def test_longer_dict(self):
        """ Test that a longer dict is encoded correctly. """

        self.n = bencode.encode_dict({"key_1": "value_1", "key_2": "value_2"})
        self.assertEquals(self.n, "d5:key_17:value_15:key_27:value_2e")
Пример #5
0
	def test_nested_dict(self):
		""" Test that a nested dict is encoded correctly. """

		self.n = bencode.encode_dict({"key":{"key":"value"}})
		self.assertEquals(self.n, "d3:keyd3:key5:valueee")
Пример #6
0
	def test_mixed_dict(self):
		""" Test that a dict with a list value is encoded correctly. """

		self.n = bencode.encode_dict({'key': ['a', 'b']})
		self.assertEquals(self.n, "d3:keyl1:a1:bee")
Пример #7
0
	def test_longer_dict(self):
		""" Test that a longer dict is encoded correctly. """

		self.n = bencode.encode_dict({"key_1":"value_1", "key_2":"value_2"})
		self.assertEquals(self.n, "d5:key_17:value_15:key_27:value_2e")
Пример #8
0
	def test_simple_dict(self):
		""" Test that a one key dict is encoded correctly. """

		self.n = bencode.encode_dict({"key":"value"})
		self.assertEquals(self.n, "d3:key5:valuee")
Пример #9
0
 def bencodeDict(self, data):
     myData = []
     bencode.encode_dict(data, myData)
     myData = "".join(myData)
     return myData