Commits

Mikhail Korobov  committed 81687b5

tests are fixed for pyhon 3.x

  • Participants
  • Parent commits 0ac1687
  • Tags 0.3

Comments (0)

Files changed (2)

File tests/test_payload.py

     def data(self):
         keys = get_random_words(10000)
         values = [key.encode('cp1251') for key in keys]
-        return zip(keys, values)
+        return list(zip(keys, values))
 
     def test_contains(self):
         data = self.data()
         keys = get_random_words(10000)
         values = [(len(key), 'ё' in key) for key in keys]
         fmt = str("<H?")
-        return fmt,  zip(keys, values)
+        return fmt, list(zip(keys, values))
 
 
     def test_getitem(self):

File tests/utils.py

 # -*- coding: utf-8 -*-
 from __future__ import absolute_import, unicode_literals
-
+import sys
 import string
 from random import choice, randint, randrange
 
+PY3 = sys.version_info[0] == 3
+
 def get_random_words(count):
     russian = 'абвгдеёжзиклмнопрстуфхцчъыьэюя'
     alphabet = russian + string.ascii_lowercase
 
 
 def get_random_binary(count):
-    def random_data(length):
-        return b"".join([chr(randint(0, 255)) for x in range(randint(1, length))])
+
+    if PY3:
+        def random_data(length):
+            return bytes(randint(0, 255) for x in range(randint(1, length)))
+    else:
+        def random_data(length):
+            return b"".join([chr(randint(0, 255)) for x in range(randint(1, length))])
+
     return list(set(random_data(10) for y in range(count)))