summarylogtreecommitdiffstats
path: root/python-uhashring-0.4.patch
blob: 0e43345ce566e157147203d26ba2714f2f75ff1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
diff --git setup.py setup.py
index 533b040..d4f9e02 100644
--- setup.py
+++ setup.py
@@ -26,8 +26,6 @@ class PyTest(TestCommand):
 
     def finalize_options(self):
         TestCommand.finalize_options(self)
-        self.test_args = []
-        self.test_suite = True
 
     def run_tests(self):
         # import here, cause outside the eggs aren't loaded
diff --git tests/test_distribution.py tests/test_distribution.py
index 651d776..ddeb29d 100644
--- tests/test_distribution.py
+++ tests/test_distribution.py
@@ -25,7 +25,7 @@ def test_distribution():
         ring['node{}'.format(i)] = {'instance': 'node_value{}'.format(i)}
 
     distribution = Counter()
-    for i in xrange(numhits):
+    for i in range(numhits):
         key = str(randint(1, numvalues))
         node = ring[key]
         distribution[node] += 1
diff --git tests/test_implementation.py tests/test_implementation.py
index cac28a9..72e9458 100644
--- tests/test_implementation.py
+++ tests/test_implementation.py
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 """
 """
+import sys
 import pytest
 import types
 
@@ -8,6 +9,8 @@ from collections import Counter
 from uhashring import HashRing
 from uuid import uuid4
 
+PY3K = sys.version_info >= (3, 0)
+
 
 @pytest.fixture
 def ring():
@@ -34,7 +37,7 @@ def ring_fast():
 
 
 def weight_fn(**conf):
-    print conf
+    print(conf)
     return int(conf['nodename'][-1])
 
 
@@ -88,6 +91,7 @@ def test_faster_ring_hashi(ring_fast):
     assert h == 12707736894140473154801792860916528374
 
 
+@pytest.mark.skipif(PY3K, reason="requires python26, python27")
 def test_range(ring):
     r = list(ring.range('test'))
     r.sort()
@@ -142,7 +146,7 @@ def test_methods_return_types(ring):
     assert isinstance(ring.get('test'), dict)
     assert isinstance(ring.get_instances(), list)
     assert isinstance(ring.get_node('test'), str)
-    assert isinstance(ring.get_nodes(), list)
+    assert isinstance(ring.get_nodes(), type({}.keys()) if PY3K else list)
     assert isinstance(ring.get_node_hostname('test'), str)
     assert isinstance(ring.get_node_port('test'), type(None))
     assert isinstance(ring.get_node_pos('test'), int)
diff --git tests/test_ketama_compatibility.py tests/test_ketama_compatibility.py
index 1b1184b..ea61c4a 100644
--- tests/test_ketama_compatibility.py
+++ tests/test_ketama_compatibility.py
@@ -16,8 +16,8 @@ from uhashring import HashRing
 @pytest.fixture
 def ketama_config_file(request):
     valid_list = NamedTemporaryFile(prefix='py.test_')
-    valid_list.write('127.0.0.1:11211\t600\n')
-    valid_list.write('127.0.0.1:11212\t400\n')
+    valid_list.write(b'127.0.0.1:11211\t600\n')
+    valid_list.write(b'127.0.0.1:11212\t400\n')
     valid_list.flush()
 
     def fin():
@@ -52,6 +52,6 @@ def test_ketama_compatibility(ketama_config_file):
 
     numhits = 1000
     numvalues = 10000
-    for i in xrange(numhits):
+    for i in range(numhits):
         key = str(randint(1, numvalues))
         assert ring.get_server(key) == continuum.get_server(key)
diff --git tox.ini tox.ini
index 6a60674..9ee6d44 100644
--- tox.ini
+++ tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py26,py27,py32,py33,py34
+envlist = py26,py27,py32,py33,py34,py35
 
 [testenv]
 deps=pytest