Merge lp:~verterok/txstatsd/py3ksupport into lp:txstatsd
- py3ksupport
- Merge into trunk
Proposed by
Guillermo Gonzalez
Status: | Merged |
---|---|
Approved by: | Guillermo Gonzalez |
Approved revision: | 108 |
Merged at revision: | 106 |
Proposed branch: | lp:~verterok/txstatsd/py3ksupport |
Merge into: | lp:txstatsd |
Diff against target: |
337 lines (+58/-39) 11 files modified
.bzrignore (+1/-0) txstatsd/metrics/distinctmetric.py (+8/-2) txstatsd/metrics/metric.py (+1/-1) txstatsd/stats/uniformsample.py (+4/-3) txstatsd/tests/metrics/test_distinct.py (+4/-3) txstatsd/tests/metrics/test_histogrammetric.py (+1/-1) txstatsd/tests/metrics/test_sli.py (+6/-2) txstatsd/tests/test_httpinfo.py (+2/-2) txstatsd/tests/test_metrics.py (+22/-21) txstatsd/tests/test_router.py (+1/-1) txstatsd/tests/test_service.py (+8/-3) |
To merge this branch: | bzr merge lp:~verterok/txstatsd/py3ksupport |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sidnei da Silva | Approve | ||
Review via email: mp+152169@code.launchpad.net |
Commit message
Initial py3k support, only the client side.
Description of the change
Initial py3k support, only the client side.
To post a comment you must log in.
Revision history for this message
Sidnei da Silva (sidnei) : | # |
review:
Approve
- 106. By Guillermo Gonzalez
-
merge with trunk
- 107. By Guillermo Gonzalez
-
also support py2.6
- 108. By Guillermo Gonzalez
-
simplify version_info check
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2011-07-07 03:29:34 +0000 | |||
3 | +++ .bzrignore 2013-03-08 13:29:21 +0000 | |||
4 | @@ -1,2 +1,3 @@ | |||
5 | 1 | _trial_temp* | 1 | _trial_temp* |
6 | 2 | twisted/plugins/dropin.cache | 2 | twisted/plugins/dropin.cache |
7 | 3 | __pycache__ | ||
8 | 3 | 4 | ||
9 | === modified file 'txstatsd/metrics/distinctmetric.py' | |||
10 | --- txstatsd/metrics/distinctmetric.py 2012-06-28 17:29:26 +0000 | |||
11 | +++ txstatsd/metrics/distinctmetric.py 2013-03-08 13:29:21 +0000 | |||
12 | @@ -28,8 +28,9 @@ | |||
13 | 28 | """ | 28 | """ |
14 | 29 | import random | 29 | import random |
15 | 30 | import time | 30 | import time |
16 | 31 | import sys | ||
17 | 31 | 32 | ||
19 | 32 | from zope.interface import implements | 33 | from zope.interface import implementer, implements |
20 | 33 | 34 | ||
21 | 34 | from txstatsd.metrics.metric import Metric | 35 | from txstatsd.metrics.metric import Metric |
22 | 35 | from txstatsd.itxstatsd import IMetric | 36 | from txstatsd.itxstatsd import IMetric |
23 | @@ -121,7 +122,8 @@ | |||
24 | 121 | Keeps an estimate of the distinct numbers of items seen on various | 122 | Keeps an estimate of the distinct numbers of items seen on various |
25 | 122 | sliding windows of time. | 123 | sliding windows of time. |
26 | 123 | """ | 124 | """ |
28 | 124 | implements(IMetric) | 125 | if sys.version_info[0:2] == (2,6): |
29 | 126 | implements(IMetric) | ||
30 | 125 | 127 | ||
31 | 126 | def __init__(self, name, wall_time_func=time.time, prefix=""): | 128 | def __init__(self, name, wall_time_func=time.time, prefix=""): |
32 | 127 | """Construct a metric we expect to be periodically updated. | 129 | """Construct a metric we expect to be periodically updated. |
33 | @@ -166,3 +168,7 @@ | |||
34 | 166 | for item, value in items.iteritems(): | 168 | for item, value in items.iteritems(): |
35 | 167 | metrics.append((self.prefix + self.name + item, value, timestamp)) | 169 | metrics.append((self.prefix + self.name + item, value, timestamp)) |
36 | 168 | return metrics | 170 | return metrics |
37 | 171 | |||
38 | 172 | # if we are running anything >= 2.7 | ||
39 | 173 | if sys.version_info[0:2] >= (2,7): | ||
40 | 174 | DistinctMetricReporter = implementer(IMetric)(DistinctMetricReporter) | ||
41 | 169 | 175 | ||
42 | === modified file 'txstatsd/metrics/metric.py' | |||
43 | --- txstatsd/metrics/metric.py 2012-06-28 17:29:26 +0000 | |||
44 | +++ txstatsd/metrics/metric.py 2013-03-08 13:29:21 +0000 | |||
45 | @@ -64,4 +64,4 @@ | |||
46 | 64 | def write(self, data): | 64 | def write(self, data): |
47 | 65 | """Message the C{data} to the C{StatsD} server.""" | 65 | """Message the C{data} to the C{StatsD} server.""" |
48 | 66 | if self.connection is not None: | 66 | if self.connection is not None: |
50 | 67 | self.connection.write(data) | 67 | self.connection.write(data.encode('utf-8')) |
51 | 68 | 68 | ||
52 | === modified file 'txstatsd/stats/uniformsample.py' | |||
53 | --- txstatsd/stats/uniformsample.py 2012-06-28 17:29:26 +0000 | |||
54 | +++ txstatsd/stats/uniformsample.py 2013-03-08 13:29:21 +0000 | |||
55 | @@ -27,7 +27,7 @@ | |||
56 | 27 | """ | 27 | """ |
57 | 28 | A random sample of a stream of values. Uses Vitter's Algorithm R to | 28 | A random sample of a stream of values. Uses Vitter's Algorithm R to |
58 | 29 | produce a statistically representative sample. | 29 | produce a statistically representative sample. |
60 | 30 | 30 | ||
61 | 31 | See: | 31 | See: |
62 | 32 | - U{Random Sampling with a Reservoir | 32 | - U{Random Sampling with a Reservoir |
63 | 33 | <http://www.cs.umd.edu/~samir/498/vitter.pdf>} | 33 | <http://www.cs.umd.edu/~samir/498/vitter.pdf>} |
64 | @@ -42,7 +42,8 @@ | |||
65 | 42 | self._values = [0 for i in range(reservoir_size)] | 42 | self._values = [0 for i in range(reservoir_size)] |
66 | 43 | self._count = 0 | 43 | self._count = 0 |
67 | 44 | self.clear() | 44 | self.clear() |
69 | 45 | 45 | self.maxint = getattr(sys, 'maxint', sys.maxsize) | |
70 | 46 | |||
71 | 46 | def clear(self): | 47 | def clear(self): |
72 | 47 | self._values = [0 for i in range(len(self._values))] | 48 | self._values = [0 for i in range(len(self._values))] |
73 | 48 | self._count = 0 | 49 | self._count = 0 |
74 | @@ -56,7 +57,7 @@ | |||
75 | 56 | if self._count <= len(self._values): | 57 | if self._count <= len(self._values): |
76 | 57 | self._values[self._count - 1] = value | 58 | self._values[self._count - 1] = value |
77 | 58 | else: | 59 | else: |
79 | 59 | r = random.randint(1, sys.maxint) % self._count | 60 | r = random.randint(1, self.maxint) % self._count |
80 | 60 | if r < len(self._values): | 61 | if r < len(self._values): |
81 | 61 | self._values[r] = value | 62 | self._values[r] = value |
82 | 62 | 63 | ||
83 | 63 | 64 | ||
84 | === modified file 'txstatsd/tests/metrics/test_distinct.py' | |||
85 | --- txstatsd/tests/metrics/test_distinct.py 2012-06-28 17:29:26 +0000 | |||
86 | +++ txstatsd/tests/metrics/test_distinct.py 2013-03-08 13:29:21 +0000 | |||
87 | @@ -18,6 +18,7 @@ | |||
88 | 18 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | 18 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
89 | 19 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | 19 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
90 | 20 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 20 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
91 | 21 | from __future__ import print_function | ||
92 | 21 | 22 | ||
93 | 22 | import random | 23 | import random |
94 | 23 | 24 | ||
95 | @@ -45,7 +46,7 @@ | |||
96 | 45 | from scipy.stats import chi2 | 46 | from scipy.stats import chi2 |
97 | 46 | except ImportError: | 47 | except ImportError: |
98 | 47 | raise SkipTest("Missing chi2, skipping") | 48 | raise SkipTest("Missing chi2, skipping") |
100 | 48 | 49 | ||
101 | 49 | N = 10000 | 50 | N = 10000 |
102 | 50 | 51 | ||
103 | 51 | for (bits, buckets) in [(-1, 1024), (24, 256), | 52 | for (bits, buckets) in [(-1, 1024), (24, 256), |
104 | @@ -61,7 +62,7 @@ | |||
105 | 61 | value = sum(((x - N / buckets) ** 2) / (N / buckets) for x in bins) | 62 | value = sum(((x - N / buckets) ** 2) / (N / buckets) for x in bins) |
106 | 62 | pval = chi2.cdf(value, N) | 63 | pval = chi2.cdf(value, N) |
107 | 63 | if pval > 0.5: | 64 | if pval > 0.5: |
109 | 64 | print bins, pval | 65 | print(bins, pval) |
110 | 65 | self.assertTrue(pval < 0.5, "bits %s, pval == %s" % (bits, pval)) | 66 | self.assertTrue(pval < 0.5, "bits %s, pval == %s" % (bits, pval)) |
111 | 66 | test_chi_square.skip = "Takes too long to run every time." | 67 | test_chi_square.skip = "Takes too long to run every time." |
112 | 67 | 68 | ||
113 | @@ -110,7 +111,7 @@ | |||
114 | 110 | 111 | ||
115 | 111 | 112 | ||
116 | 112 | class TestPlugin(TestCase): | 113 | class TestPlugin(TestCase): |
118 | 113 | 114 | ||
119 | 114 | def test_factory(self): | 115 | def test_factory(self): |
120 | 115 | self.assertTrue(distinct_plugin.distinct_metric_factory in \ | 116 | self.assertTrue(distinct_plugin.distinct_metric_factory in \ |
121 | 116 | list(getPlugins(IMetricFactory))) | 117 | list(getPlugins(IMetricFactory))) |
122 | 117 | 118 | ||
123 | === modified file 'txstatsd/tests/metrics/test_histogrammetric.py' | |||
124 | --- txstatsd/tests/metrics/test_histogrammetric.py 2012-06-28 17:29:26 +0000 | |||
125 | +++ txstatsd/tests/metrics/test_histogrammetric.py 2013-03-08 13:29:21 +0000 | |||
126 | @@ -102,7 +102,7 @@ | |||
127 | 102 | histogram.update(i) | 102 | histogram.update(i) |
128 | 103 | 103 | ||
129 | 104 | hist = histogram.histogram() | 104 | hist = histogram.histogram() |
131 | 105 | self.assertEquals(sum(hist), 10000) | 105 | self.assertEqual(sum(hist), 10000) |
132 | 106 | 106 | ||
133 | 107 | total = sum(hist) | 107 | total = sum(hist) |
134 | 108 | binsize = int(total / len(hist)) | 108 | binsize = int(total / len(hist)) |
135 | 109 | 109 | ||
136 | === modified file 'txstatsd/tests/metrics/test_sli.py' | |||
137 | --- txstatsd/tests/metrics/test_sli.py 2012-06-28 17:29:26 +0000 | |||
138 | +++ txstatsd/tests/metrics/test_sli.py 2013-03-08 13:29:21 +0000 | |||
139 | @@ -20,8 +20,12 @@ | |||
140 | 20 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | 20 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
141 | 21 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
142 | 22 | 22 | ||
145 | 23 | import ConfigParser | 23 | try: |
146 | 24 | from cStringIO import StringIO | 24 | import ConfigParser |
147 | 25 | from StringIO import StringIO | ||
148 | 26 | except ImportError: | ||
149 | 27 | import configparser as ConfigParser | ||
150 | 28 | from io import StringIO | ||
151 | 25 | from twisted.trial.unittest import TestCase | 29 | from twisted.trial.unittest import TestCase |
152 | 26 | 30 | ||
153 | 27 | from twisted.plugins.sli_plugin import SLIMetricFactory | 31 | from twisted.plugins.sli_plugin import SLIMetricFactory |
154 | 28 | 32 | ||
155 | === modified file 'txstatsd/tests/test_httpinfo.py' | |||
156 | --- txstatsd/tests/test_httpinfo.py 2012-06-28 17:29:26 +0000 | |||
157 | +++ txstatsd/tests/test_httpinfo.py 2013-03-08 13:29:21 +0000 | |||
158 | @@ -111,7 +111,7 @@ | |||
159 | 111 | def test_httpinfo_error(self): | 111 | def test_httpinfo_error(self): |
160 | 112 | try: | 112 | try: |
161 | 113 | data = yield self.get_results("status", last_flush_duration=30) | 113 | data = yield self.get_results("status", last_flush_duration=30) |
163 | 114 | except HttpException, e: | 114 | except HttpException as e: |
164 | 115 | self.assertEquals(e.response.code, 500) | 115 | self.assertEquals(e.response.code, 500) |
165 | 116 | else: | 116 | else: |
166 | 117 | self.fail("Not 500") | 117 | self.fail("Not 500") |
167 | @@ -121,7 +121,7 @@ | |||
168 | 121 | try: | 121 | try: |
169 | 122 | data = yield self.get_results("metrics/gorets", | 122 | data = yield self.get_results("metrics/gorets", |
170 | 123 | timer_metrics={'gorets': 100}) | 123 | timer_metrics={'gorets': 100}) |
172 | 124 | except HttpException, e: | 124 | except HttpException as e: |
173 | 125 | self.assertEquals(e.response.code, 404) | 125 | self.assertEquals(e.response.code, 404) |
174 | 126 | else: | 126 | else: |
175 | 127 | self.fail("Not 404") | 127 | self.fail("Not 404") |
176 | 128 | 128 | ||
177 | === modified file 'txstatsd/tests/test_metrics.py' | |||
178 | --- txstatsd/tests/test_metrics.py 2012-06-28 17:29:26 +0000 | |||
179 | +++ txstatsd/tests/test_metrics.py 2013-03-08 13:29:21 +0000 | |||
180 | @@ -52,28 +52,29 @@ | |||
181 | 52 | """Test reporting of a gauge metric sample.""" | 52 | """Test reporting of a gauge metric sample.""" |
182 | 53 | self.metrics.gauge('gauge', 102) | 53 | self.metrics.gauge('gauge', 102) |
183 | 54 | self.assertEqual(self.connection.data, | 54 | self.assertEqual(self.connection.data, |
185 | 55 | 'txstatsd.tests.gauge:102|g') | 55 | b'txstatsd.tests.gauge:102|g') |
186 | 56 | 56 | ||
187 | 57 | def test_meter(self): | 57 | def test_meter(self): |
188 | 58 | """Test reporting of a meter metric sample.""" | 58 | """Test reporting of a meter metric sample.""" |
189 | 59 | self.metrics.meter('meter', 3) | 59 | self.metrics.meter('meter', 3) |
190 | 60 | self.assertEqual(self.connection.data, | 60 | self.assertEqual(self.connection.data, |
192 | 61 | 'txstatsd.tests.meter:3|m') | 61 | b'txstatsd.tests.meter:3|m') |
193 | 62 | 62 | ||
194 | 63 | def test_counter(self): | 63 | def test_counter(self): |
195 | 64 | """Test the increment and decrement operations.""" | 64 | """Test the increment and decrement operations.""" |
196 | 65 | self.metrics.increment('counter', 18) | 65 | self.metrics.increment('counter', 18) |
197 | 66 | self.assertEqual(self.connection.data, | 66 | self.assertEqual(self.connection.data, |
199 | 67 | 'txstatsd.tests.counter:18|c') | 67 | b'txstatsd.tests.counter:18|c') |
200 | 68 | self.metrics.decrement('counter', 9) | 68 | self.metrics.decrement('counter', 9) |
201 | 69 | self.assertEqual(self.connection.data, | 69 | self.assertEqual(self.connection.data, |
203 | 70 | 'txstatsd.tests.counter:-9|c') | 70 | b'txstatsd.tests.counter:-9|c') |
204 | 71 | 71 | ||
205 | 72 | def test_timing(self): | 72 | def test_timing(self): |
206 | 73 | """Test the timing operation.""" | 73 | """Test the timing operation.""" |
207 | 74 | self.metrics.timing('timing', 101.1234) | 74 | self.metrics.timing('timing', 101.1234) |
210 | 75 | self.assertEqual(self.connection.data, | 75 | # to support both 2 and 3, can't use assertRegex |
211 | 76 | 'txstatsd.tests.timing:101123.4|ms') | 76 | match = re.match(b'txstatsd.tests.timing:101123.4[0-9]*|ms', self.connection.data) |
212 | 77 | self.assertFalse(match is None) | ||
213 | 77 | 78 | ||
214 | 78 | def test_timing_automatic(self): | 79 | def test_timing_automatic(self): |
215 | 79 | """Test the automatic timing operation with explicit reset""" | 80 | """Test the automatic timing operation with explicit reset""" |
216 | @@ -85,9 +86,9 @@ | |||
217 | 85 | 86 | ||
218 | 86 | elapsed = time.time() - start_time | 87 | elapsed = time.time() - start_time |
219 | 87 | 88 | ||
223 | 88 | label, val, units = re.split(":|\|", self.connection.data) | 89 | label, val, units = re.split(b":|\|", self.connection.data) |
224 | 89 | self.assertEqual(label, 'txstatsd.tests.timing') | 90 | self.assertEqual(label, b'txstatsd.tests.timing') |
225 | 90 | self.assertEqual(units, 'ms') | 91 | self.assertEqual(units, b'ms') |
226 | 91 | self.assertTrue(100 <= float(val) <= elapsed * 1000) | 92 | self.assertTrue(100 <= float(val) <= elapsed * 1000) |
227 | 92 | 93 | ||
228 | 93 | def test_timing_automatic_implicit_reset(self): | 94 | def test_timing_automatic_implicit_reset(self): |
229 | @@ -100,34 +101,34 @@ | |||
230 | 100 | 101 | ||
231 | 101 | elapsed = time.time() - start_time | 102 | elapsed = time.time() - start_time |
232 | 102 | 103 | ||
236 | 103 | label, val, units = re.split(":|\|", self.connection.data) | 104 | label, val, units = re.split(b":|\|", self.connection.data) |
237 | 104 | self.assertEqual(label, 'txstatsd.tests.timing') | 105 | self.assertEqual(label, b'txstatsd.tests.timing') |
238 | 105 | self.assertEqual(units, 'ms') | 106 | self.assertEqual(units, b'ms') |
239 | 106 | self.assertTrue(100 <= float(val) <= elapsed * 1000) | 107 | self.assertTrue(100 <= float(val) <= elapsed * 1000) |
240 | 107 | 108 | ||
241 | 108 | def test_generic(self): | 109 | def test_generic(self): |
242 | 109 | """Test the GenericMetric class.""" | 110 | """Test the GenericMetric class.""" |
243 | 110 | self.metrics.report('users', "pepe", "pd") | 111 | self.metrics.report('users', "pepe", "pd") |
244 | 111 | self.assertEqual(self.connection.data, | 112 | self.assertEqual(self.connection.data, |
246 | 112 | 'txstatsd.tests.users:pepe|pd') | 113 | b'txstatsd.tests.users:pepe|pd') |
247 | 113 | 114 | ||
248 | 114 | def test_generic_extra(self): | 115 | def test_generic_extra(self): |
249 | 115 | """Test the GenericMetric class.""" | 116 | """Test the GenericMetric class.""" |
250 | 116 | self.metrics.report('users', "pepe", "pd", 100) | 117 | self.metrics.report('users', "pepe", "pd", 100) |
251 | 117 | self.assertEqual(self.connection.data, | 118 | self.assertEqual(self.connection.data, |
253 | 118 | 'txstatsd.tests.users:pepe|pd|100') | 119 | b'txstatsd.tests.users:pepe|pd|100') |
254 | 119 | 120 | ||
255 | 120 | def test_empty_namespace(self): | 121 | def test_empty_namespace(self): |
256 | 121 | """Test reporting of an empty namespace.""" | 122 | """Test reporting of an empty namespace.""" |
257 | 122 | self.metrics.namespace = None | 123 | self.metrics.namespace = None |
258 | 123 | self.metrics.gauge('gauge', 213) | 124 | self.metrics.gauge('gauge', 213) |
259 | 124 | self.assertEqual(self.connection.data, | 125 | self.assertEqual(self.connection.data, |
261 | 125 | 'gauge:213|g') | 126 | b'gauge:213|g') |
262 | 126 | 127 | ||
263 | 127 | self.metrics.namespace = '' | 128 | self.metrics.namespace = '' |
264 | 128 | self.metrics.gauge('gauge', 413) | 129 | self.metrics.gauge('gauge', 413) |
265 | 129 | self.assertEqual(self.connection.data, | 130 | self.assertEqual(self.connection.data, |
267 | 130 | 'gauge:413|g') | 131 | b'gauge:413|g') |
268 | 131 | 132 | ||
269 | 132 | 133 | ||
270 | 133 | class TestExtendedMetrics(TestMetrics): | 134 | class TestExtendedMetrics(TestMetrics): |
271 | @@ -139,21 +140,21 @@ | |||
272 | 139 | """Test the increment and decrement operations.""" | 140 | """Test the increment and decrement operations.""" |
273 | 140 | self.metrics.increment('counter', 18) | 141 | self.metrics.increment('counter', 18) |
274 | 141 | self.assertEqual(self.connection.data, | 142 | self.assertEqual(self.connection.data, |
276 | 142 | 'txstatsd.tests.counter:18|c') | 143 | b'txstatsd.tests.counter:18|c') |
277 | 143 | self.metrics.decrement('counter', 9) | 144 | self.metrics.decrement('counter', 9) |
278 | 144 | self.assertEqual(self.connection.data, | 145 | self.assertEqual(self.connection.data, |
280 | 145 | 'txstatsd.tests.counter:9|c') | 146 | b'txstatsd.tests.counter:9|c') |
281 | 146 | 147 | ||
282 | 147 | def test_sli(self): | 148 | def test_sli(self): |
283 | 148 | """Test SLI call.""" | 149 | """Test SLI call.""" |
284 | 149 | self.metrics.sli('users', 100) | 150 | self.metrics.sli('users', 100) |
285 | 150 | self.assertEqual(self.connection.data, | 151 | self.assertEqual(self.connection.data, |
287 | 151 | 'txstatsd.tests.users:100|sli') | 152 | b'txstatsd.tests.users:100|sli') |
288 | 152 | 153 | ||
289 | 153 | self.metrics.sli('users', 200, 2) | 154 | self.metrics.sli('users', 200, 2) |
290 | 154 | self.assertEqual(self.connection.data, | 155 | self.assertEqual(self.connection.data, |
292 | 155 | 'txstatsd.tests.users:200|sli|2') | 156 | b'txstatsd.tests.users:200|sli|2') |
293 | 156 | 157 | ||
294 | 157 | self.metrics.sli_error('users') | 158 | self.metrics.sli_error('users') |
295 | 158 | self.assertEqual(self.connection.data, | 159 | self.assertEqual(self.connection.data, |
297 | 159 | 'txstatsd.tests.users:error|sli') | 160 | b'txstatsd.tests.users:error|sli') |
298 | 160 | 161 | ||
299 | === modified file 'txstatsd/tests/test_router.py' | |||
300 | --- txstatsd/tests/test_router.py 2012-06-28 17:29:26 +0000 | |||
301 | +++ txstatsd/tests/test_router.py 2013-03-08 13:29:21 +0000 | |||
302 | @@ -179,7 +179,7 @@ | |||
303 | 179 | 179 | ||
304 | 180 | class Collect(DatagramProtocol): | 180 | class Collect(DatagramProtocol): |
305 | 181 | 181 | ||
307 | 182 | def datagramReceived(cself, data, (host, port)): | 182 | def datagramReceived(cself, data, host_port): |
308 | 183 | self.got_data(data) | 183 | self.got_data(data) |
309 | 184 | 184 | ||
310 | 185 | self.port = reactor.listenUDP(0, Collect()) | 185 | self.port = reactor.listenUDP(0, Collect()) |
311 | 186 | 186 | ||
312 | === modified file 'txstatsd/tests/test_service.py' | |||
313 | --- txstatsd/tests/test_service.py 2012-06-28 17:29:26 +0000 | |||
314 | +++ txstatsd/tests/test_service.py 2013-03-08 13:29:21 +0000 | |||
315 | @@ -20,8 +20,12 @@ | |||
316 | 20 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 20 | # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
317 | 21 | 21 | ||
318 | 22 | import tempfile | 22 | import tempfile |
321 | 23 | import ConfigParser | 23 | try: |
322 | 24 | from StringIO import StringIO | 24 | import ConfigParser |
323 | 25 | from StringIO import StringIO | ||
324 | 26 | except ImportError: | ||
325 | 27 | import configparser as ConfigParser | ||
326 | 28 | from io import StringIO | ||
327 | 25 | 29 | ||
328 | 26 | from twisted.trial.unittest import TestCase | 30 | from twisted.trial.unittest import TestCase |
329 | 27 | 31 | ||
330 | @@ -203,7 +207,8 @@ | |||
331 | 203 | def __init__(self): | 207 | def __init__(self): |
332 | 204 | self.monitor_response = None | 208 | self.monitor_response = None |
333 | 205 | 209 | ||
335 | 206 | def datagramReceived(self, data, (host, port)): | 210 | def datagramReceived(self, data, host_port): |
336 | 211 | host, port = host_port | ||
337 | 207 | self.monitor_response = data | 212 | self.monitor_response = data |
338 | 208 | 213 | ||
339 | 209 | 214 |